Search code examples
msbuildnugetportable-class-library.net-4.6.net-core

Portable library causes: Found conflicts between different versions of the same dependent assembly that could not be resolved


I have created "Contracts" Portable Class Library targeting .net 4.6, ASP.NET Core and Windows 10. This library contains only POCO classes.

I have another project called "Communications" targeting .net 4.6 and referencing the portable library:

enter image description here

When I try to build the project, I'm getting warning:

Description: Found conflicts between different versions of the same dependent assembly that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.    
Project:     Communication
File:        C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets
Line         1819

the detailed build log is here: buildlog.txt

Why am I getting this warning? How to get rid of it?

here are parts from the build log that may be relevant:

1>  Unified Dependency "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>      Using this version instead of original version "1.5.0.0" in "C:\Projects\MySolution\packages\System.Net.Http.Formatting.Extension.5.2.3.0\lib\System.Net.Http.Extensions.dll" because AutoUnify is 'true'.
1>      Resolved file path is "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Net.Http.dll".
1>      Reference found at search path location "{TargetFrameworkDirectory}".
1>          For SearchPath "C:\Projects\MySolution\packages\System.Net.Http.Formatting.Extension.5.2.3.0\lib".
1>          Considered "C:\Projects\MySolution\packages\System.Net.Http.Formatting.Extension.5.2.3.0\lib\System.Net.Http.winmd", but it didn't exist.
1>          Considered "C:\Projects\MySolution\packages\System.Net.Http.Formatting.Extension.5.2.3.0\lib\System.Net.Http.dll", but it didn't exist.
1>          Considered "C:\Projects\MySolution\packages\System.Net.Http.Formatting.Extension.5.2.3.0\lib\System.Net.Http.exe", but it didn't exist.
1>          For SearchPath "{TargetFrameworkDirectory}".
1>          Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Net.Http.winmd", but it didn't exist.
1>      Required by "System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL".
1>      Required by "System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL".
1>      This reference is not "CopyLocal" because it conflicted with another reference with the same name and lost the conflict.
1>      The ImageRuntimeVersion for this reference is "v4.0.30319".

...

1>  Dependency "System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes".
1>      Could not resolve this reference. Could not locate the assembly "System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
1>          For SearchPath "C:\Projects\MySolution\packages\System.Net.Http.Formatting.Extension.5.2.3.0\lib".
1>          Considered "C:\Projects\MySolution\packages\System.Net.Http.Formatting.Extension.5.2.3.0\lib\System.Core.winmd", but it didn't exist.
1>          Considered "C:\Projects\MySolution\packages\System.Net.Http.Formatting.Extension.5.2.3.0\lib\System.Core.dll", but it didn't exist.
etc...
1>          For SearchPath "{Registry:Software\Microsoft\.NETFramework,v4.6,AssemblyFoldersEx}".
1>          Considered AssemblyFoldersEx locations.
1>          For SearchPath "{AssemblyFolders}".
1>          Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\System.Core.winmd", but it didn't exist.
1>          Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\System.Core.dll", but it didn't exist.
etc...
1>          For SearchPath "{GAC}".
1>          Considered "System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes", which was not found in the GAC.
1>          For SearchPath "bin\Debug\".
1>          Considered "bin\Debug\System.Core.winmd", but it didn't exist.
1>          Considered "bin\Debug\System.Core.dll", but it didn't exist.
1>          Considered "bin\Debug\System.Core.exe", but it didn't exist.
1>      Required by "System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL".

...

1>  There was a conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes".
1>      "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" was chosen because it was primary and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes" was not.
1>      References which depend on "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\mscorlib.dll].
1>          C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\mscorlib.dll
1>            Project file item includes which caused reference "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\mscorlib.dll".
1>              System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
1>              C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\mscorlib.dll
1>              Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL
1>          C:\Projects\MySolution\packages\System.Net.Http.Formatting.Extension.5.2.3.0\lib\System.Net.Http.Formatting.dll
1>            Project file item includes which caused reference "C:\Projects\MySolution\packages\System.Net.Http.Formatting.Extension.5.2.3.0\lib\System.Net.Http.Formatting.dll".
1>              System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
1>          C:\Projects\MySolution\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll
1>            Project file item includes which caused reference "C:\Projects\MySolution\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll".
1>              System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
1>              Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL
1>      References which depend on "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes" [].
1>          C:\Projects\MySolution\packages\System.Net.Http.Formatting.Extension.5.2.3.0\lib\System.Net.Http.Extensions.dll
1>            Project file item includes which caused reference "C:\Projects\MySolution\packages\System.Net.Http.Formatting.Extension.5.2.3.0\lib\System.Net.Http.Extensions.dll".
1>              System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL

Solution

  • I have updated nuget package System.Net.Http in my .net 4.6 project and the warning disappeared. Generally, it is quite difficult to find root of this kind of issues. .NET distributed via nugget is gonna be mess in the future.