Reputation: 5846
I recently updated an ASP.NET MVC 5 project from .NET Framework 4.5.1 to 4.6.1. I also updated NuGet packages.
Now when I build the project I see several dozen warnings of Encountered conflict between ...
I've included several of these entries from the VS Output window:
1>_HandlePackageFileConflicts:
1> Encountered conflict between 'Reference:Microsoft.Win32.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL' and 'Reference:Microsoft.Win32.Primitives'. Choosing 'Reference:Microsoft.Win32.Primitives' because AssemblyVersion '4.0.3.0' is greater than '4.0.2.0'.
1> Encountered conflict between 'Reference:System.AppContext, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL' and 'Reference:System.AppContext'. Choosing 'Reference:System.AppContext' because AssemblyVersion '4.1.2.0' is greater than '4.0.0.0'.
1> Encountered conflict between 'Reference:System.Console, Version=4.0.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL' and 'Reference:System.Console'. Choosing 'Reference:System.Console' because AssemblyVersion '4.0.2.0' is greater than '4.0.1.1'.
1> Encountered conflict between 'Reference:System.Diagnostics.TraceSource, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL' and 'Reference:System.Diagnostics.TraceSource'. Choosing 'Reference:System.Diagnostics.TraceSource' because AssemblyVersion '4.0.2.0' is greater than '4.0.1.0'.
1> Encountered conflict between 'Reference:System.Globalization.Calendars, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL' and 'Reference:System.Globalization.Calendars'. Choosing 'Reference:System.Globalization.Calendars' because AssemblyVersion '4.0.3.0' is greater than '4.0.2.0'.
The packages.config
file contains what looks like correct version references:
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net461" />
<package id="Microsoft.Win32.Registry" version="4.5.0" targetFramework="net461" />
And the packages/ folder contains the correct versions as well. 4.3.0 and 4.5.0 for the 2 entries above.
How do I resolve these conflicts?
* *
UPDATE
There is a Reference to Microsoft.Win32.Primitives with a Path of
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\Microsoft.Win32.Primitives.dll
The reference is configured when the NuGet package is installed. I'm not understanding why NuGet is installing v4.3.0 and adding a Reference in the project to an extension that's v4.0.2.0 and yet resolving the conflict by using v4.3.0 since it's newer.
This is confusing behavior. It works fine on my local PC, but I'm having a subtle issue on one of the staging servers after publishing. I suspect there's one or more packages where this conflict isn't resolved correctly on the staging server.
I'm trying to figure out how to eliminate the eenie-meenie-minie-moe selection of these dependencies. :S
Upvotes: 2
Views: 1195
Reputation: 76760
.NET Framework update leaves build with “Encountered conflict between …” warnings
That is because:
This is due to the injected support for NETStandard 2.0. We inject new assemblies into NET 4.6.1 and later desktop projects in order to add support for netstandard2.0. We do this in targets now instead of packages because its no longer a requirement to reference a package to build a netstandard library. This injection happens whenever we see a netstandard1.5 or greater library referenced (see dotnet/sdk#1386).
Check this thread for some more details.
To resolve this issue, you could add binding redirect to those reference or just use standard references to Microsoft.Win32.Primitives
and not bring in any Nuget package for Microsoft.Win32.Primitives
.
See System.Net.Http v4.2.0.0 being copied/loaded from MSBuild tooling for some details.
Hope this helps.
Upvotes: 3