Search code examples
deployment.net-coreevent-log

Deploying .NET Core Application with Windows Compatibility Pack


I'm busy deploying a .NET Core 2.1 application into our testing environment, but I'm getting the following error.

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'

We are using the Windows Compatibility Pack to access the Event Log.

I have the following item in the dependency Json file:

"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"
    }
  }
}

Please advise how one should deploy these dependencies. Also, what is the root folder to this relative path runtimes/win/lib/netcoreapp2.0?


Solution

  • We actually found a solution for our scenario: - Our situation was that we tried to run a netcoreapp based test project on our test agent - dotnet test on the project file worked - dotnet vstest sometimes worked on the project output directory (we are not sure why and on which setup) - dotnet vstest did run into the above error when run into an other directory & downloaded from CI - dotnet vstest did run into an AssemblyNotFoundException on the test agent (which didn't make any sense for us)

    The solution was to use dotnet publish for our test project and use the "self-contained" output to run on the test agent. dotnet publish copied the required runtimes/win/lib/netcoreappX.X/*.dll files into the publish output directory.