Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conflict between two referenced assemblies

I'm playing with .Net Core application which is working fine. However, today I found that output contains a warning. After setting log level to detailed I found following:

2>    Dependency "Microsoft.Extensions.DependencyModel, Version=1.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60".
2>        Could not resolve this reference. Could not locate the assembly "Microsoft.Extensions.DependencyModel, Version=1.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
2>            For SearchPath "C:\Users\Alex\.nuget\packages\microsoft.testplatform.testhost\15.0.0-preview-20161123-03\lib\netstandard1.5".
2>            Considered "C:\Users\Alex\.nuget\packages\microsoft.testplatform.testhost\15.0.0-preview-20161123-03\lib\netstandard1.5\Microsoft.Extensions.DependencyModel.winmd", but it didn't exist.
2>            Considered "C:\Users\Alex\.nuget\packages\microsoft.testplatform.testhost\15.0.0-preview-20161123-03\lib\netstandard1.5\Microsoft.Extensions.DependencyModel.dll", but it didn't exist.
2>            Considered "C:\Users\Alex\.nuget\packages\microsoft.testplatform.testhost\15.0.0-preview-20161123-03\lib\netstandard1.5\Microsoft.Extensions.DependencyModel.exe", but it didn't exist.
2>            For SearchPath "{CandidateAssemblyFiles}".
2>            Considered "C:\Users\Alex\.nuget\packages\xunit.runner.visualstudio\2.2.0-beta4-build1194\build\netcoreapp1.0\xunit.runner.visualstudio.dotnetcore.testadapter.dll",
2>              but its name "xunit.runner.visualstudio.dotnetcore.testadapter"
2>              didn't match the expected name "Microsoft.Extensions.DependencyModel, Version=1.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60".
2>            Considered "C:\Users\Alex\.nuget\packages\xunit.runner.visualstudio\2.2.0-beta4-build1194\build\netcoreapp1.0\xunit.runner.utility.dotnet.dll",
2>              but its name "xunit.runner.utility.dotnet"
2>              didn't match the expected name "Microsoft.Extensions.DependencyModel, Version=1.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60".
2>        Required by "C:\Users\Alex\.nuget\packages\microsoft.testplatform.testhost\15.0.0-preview-20161123-03\lib\netstandard1.5\testhost.dll".
2>        Required by "C:\Users\Alex\.nuget\packages\microsoft.testplatform.testhost\15.0.0-preview-20161123-03\lib\netstandard1.5\Microsoft.TestPlatform.CrossPlatEngine.dll".
2>    There was a conflict between "Microsoft.Extensions.DependencyModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" and "Microsoft.Extensions.DependencyModel, Version=1.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60".
2>        "Microsoft.Extensions.DependencyModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" was chosen because it was primary and "Microsoft.Extensions.DependencyModel, Version=1.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" was not.
2>        References which depend on "Microsoft.Extensions.DependencyModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" [C:\Users\Alex\.nuget\packages\microsoft.extensions.dependencymodel\1.0.0\lib\netstandard1.6\Microsoft.Extensions.DependencyModel.dll].
2>            C:\Users\Alex\.nuget\packages\microsoft.extensions.dependencymodel\1.0.0\lib\netstandard1.6\Microsoft.Extensions.DependencyModel.dll
2>              Project file item includes which caused reference "C:\Users\Alex\.nuget\packages\microsoft.extensions.dependencymodel\1.0.0\lib\netstandard1.6\Microsoft.Extensions.DependencyModel.dll".
2>                C:\Users\Alex\.nuget\packages\microsoft.extensions.dependencymodel\1.0.0\lib\netstandard1.6\Microsoft.Extensions.DependencyModel.dll
2>        References which depend on "Microsoft.Extensions.DependencyModel, Version=1.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" [].
2>            C:\Users\Alex\.nuget\packages\microsoft.testplatform.testhost\15.0.0-preview-20161123-03\lib\netstandard1.5\Microsoft.TestPlatform.CrossPlatEngine.dll
2>              Project file item includes which caused reference "C:\Users\Alex\.nuget\packages\microsoft.testplatform.testhost\15.0.0-preview-20161123-03\lib\netstandard1.5\Microsoft.TestPlatform.CrossPlatEngine.dll".
2>                C:\Users\Alex\.nuget\packages\microsoft.testplatform.testhost\15.0.0-preview-20161123-03\lib\netstandard1.5\testhost.dll
2>                C:\Users\Alex\.nuget\packages\microsoft.testplatform.testhost\15.0.0-preview-20161123-03\lib\netstandard1.5\Microsoft.TestPlatform.CrossPlatEngine.dll
2>    C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1909,5): warning MSB3277: 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.
2>  Done executing task "ResolveAssemblyReference".

The line There was a conflict between "Microsoft.Extensions.DependencyModel.... I don't know hot to work around this warning, because I'm just using .Net standard 1.1 and System.Reflection.Emit package from NuGet and do not reference anything else.

Of course, I can just ignore this warning, but looking for some solution

like image 542
Alex Zhukovskiy Avatar asked Jan 20 '17 10:01

Alex Zhukovskiy


1 Answers

According to the detailed log, We found that dependency "Microsoft.Extensions.DependencyModel, Version=1.0.1.0, which is required by your code. But this dependency with Version=1.0.0.0 is installed already.

So when we compile the project, the this dependency with Version=1.0.0.0 will be chosen, which will cause that conflict. So you can use NuGet to add the dependency “Microsoft.Extensions.DependencyModel” with the specify version=1.0.1.0 to solve this warning issue.

like image 171
Zhanglong Wu - MSFT Avatar answered Sep 20 '22 12:09

Zhanglong Wu - MSFT