.net core application fails with the following message:
2021-05-06T11:48:20.114165977Z Unhandled exception. System.TypeInitializationException: The type initializer for 'Audit.Core.Configuration' threw an exception.2021-05-06T11:48:20.114232677Z ---> System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.
My code doesn't have any explicit dependencies on Newtonsoft.Json, by inspecting the project.assets.json file I can see the following picture:
- App code depends on Microsoft.Extensions.Configuration.AzureKeyVault depends on Microsoft.Azure.KeyVault which depends on "Newtonsoft.Json": "9.0.1".
- App code depends on Audit.EntityFramework.Core depends on "Newtonsoft.Json": "12.0.2"
- App code depends on Audit.WebApi.Core depends on "Newtonsoft.Json": "12.0.2"
When I run dotnet publish
command the Newtonsoft.Json version is always 9.0.0.0 in a published directory. My question is, how it would be possible to control the version of the Newtonsoft.Json so the higher version will be published during the build/publish.