deployment - 使用 Windows 兼容包部署 .NET Core 应用程序

标签 deployment .net-core event-log

我正忙于将 .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/

相关文章:

java - 如何将依赖项的测试 jar 包含到 Maven 项目的部署中?

java - 自动将Java应用程序更新为Windows可安装的

.net-core - EF Core 工具无法正确安装

javascript - Angular2 中的文件上传不起作用

.net - 如何按应用程序名称过滤 Windows 事件查看器?(寻找我的 c#/wpf 崩溃)

go - 如何将此功能部署到Google Cloud?

deployment - 如何避免 glassfish 部署所有以前的项目?

c# - 为什么导入 speedscope 后在 Linux 中跟踪 C# 代码会失败?

.net-4.5 - ETW、.NET 4.5 - 如何写入事件日志?

python - 使用 pywin32(win32evtlog 模块)在 Python 中读取 Windows 事件日志