我正忙于将 .NET Core 2.1 应用程序部署到我们的测试环境中,但收到以下错误。
Error:
An assembly specified in the application dependencies manifest (MyApp.deps.json) was not found:
package: 'System.Diagnostics.EventLog', version: '4.5.0'
path: 'runtimes/win/lib/netcoreapp2.1/System.Diagnostics.EventLog.dll'
我们正在使用 Windows Compatibility Pack访问事件日志。
我的依赖 Json 文件中有以下项目:
"System.Diagnostics.EventLog/4.5.0": {
"dependencies": {
"Microsoft.Win32.Registry": "4.5.0",
"System.Security.Permissions": "4.5.0",
"System.Security.Principal.Windows": "4.5.0",
"System.Threading.AccessControl": "4.5.0"
},
"runtime": {
"lib/netstandard2.0/System.Diagnostics.EventLog.dll": {
"assemblyVersion": "4.0.0.0",
"fileVersion": "4.6.26515.6"
}
},
"runtimeTargets": {
"runtimes/win/lib/netcoreapp2.0/System.Diagnostics.EventLog.dll": {
"rid": "win",
"assetType": "runtime",
"assemblyVersion": "4.0.0.0",
"fileVersion": "4.6.26515.6"
}
}
}
请告知应如何部署这些依赖项。另外,这个相对路径runtimes/win/lib/netcoreapp2.0
的根文件夹是什么?
最佳答案
我们实际上找到了适合我们场景的解决方案:
- 我们的情况是,我们尝试在我们的测试代理上运行基于 netcoreapp 的测试项目
- 项目文件上的 dotnet test
有效
- dotnet vstest
有时在项目输出目录上工作(我们不确定为什么以及在哪个设置上)
- dotnet vstest
在运行到其他目录并从 CI 下载时确实遇到了上述错误
- dotnet vstest
在测试代理上确实遇到了 AssemblyNotFoundException
(这对我们来说没有任何意义)
解决方案是为我们的测试项目使用 dotnetpublish
并使用“独立”输出在测试代理上运行。 dotnetpublish
将所需的 runtimes/win/lib/netcoreappX.X/*.dll
文件复制到发布输出目录中。
关于deployment - 使用 Windows 兼容包部署 .NET Core 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53420187/