I'm trying to get log4net working under a dotnetcore3.1 project. I am continuously getting spammed with errors like this:
error NU1605: Detected package downgrade: System.Diagnostics.Debug from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version. [/app/MyProject.csproj]
csproj boils down to this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<OutputType>exe</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="log4net" Version="2.0.8" />
</ItemGroup>
</Project>
Environment:
- dotnetcore3.1
- docker build image: mcr.microsoft.com/dotnet/core/sdk:3.1
- docker runtime image: mcr.microsoft.com/dotnet/core/runtime:3.1-bionic
Unacceptable "fixes":
- "Just add
<WarningsAsErrors></WarningsAsErrors>
" - Anything that involves opening Visual Studio
There are several posts for this problem, but they seem to either suppress the error and move on, or they use Visual Studio "magic" to solve it.
Based on this message, Reference the package directly from the project to select a different version.
, I've tried adding package references to my csproj, but none of "System", "System.Diagnostics", or "System.Diagnostics.Debug" work.
How do you actually fix this problem?
Please be specific. I'm still new to C# and many solutions I've found may not have worked because they simply said add <SomeXmlTag />
and I had no idea where to put it or under what parent to drop the tag.
Per Gray Cat, I tried: Adding a bindingRedirect to a .Net Standard library
Originally it didn't seem like it changed the output at all. After playing with the verbosity, I found this:
"/app/MyProject.csproj" (Publish target) (1) ->
(ResolveAssemblyReferences target) ->
/usr/share/dotnet/sdk/3.1.100/Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3277: Found conflicts between different versions of "System.Configuration.ConfigurationManager" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [/app/MyProject.csproj]
/usr/share/dotnet/sdk/3.1.100/Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3277: Found conflicts between different versions of "System.Security.AccessControl" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [/app/MyProject.csproj]
/usr/share/dotnet/sdk/3.1.100/Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3277: Found conflicts between different versions of "System.Security.Permissions" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [/app/MyProject.csproj]
/usr/share/dotnet/sdk/3.1.100/Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3277: Found conflicts between different versions of "System.Security.Principal.Windows" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. [/app/MyProject.csproj]
Wonderfully, it's supposed to include the details, but I can't find them in the pages of output I'm looking at.