移植库原因:发现同一个依赖程序集的不同版本之间存在冲突无法解决
Portable library causes: Found conflicts between different versions of the same dependent assembly that could not be resolved
我创建了 "Contracts" Portable Class 库,目标是 .net 4.6,ASP.NET Core 和 Windows 10。这个库只包含 POCO 类。
我有另一个名为 "Communications" 的项目,目标是 .net 4.6 并引用可移植库:
当我尝试构建项目时,我收到警告:
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.0\bin\Microsoft.Common.CurrentVersion.targets
Line 1819
详细的构建日志在这里:buildlog.txt
为什么我会收到此警告?如何摆脱它?
以下是构建日志中可能相关的部分:
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
我在我的 .net 4.6 项目中更新了 nuget 包 System.Net.Http,警告消失了。
通常,很难找到此类问题的根源。通过 nugget 分发的 .NET 将来会一团糟。
我创建了 "Contracts" Portable Class 库,目标是 .net 4.6,ASP.NET Core 和 Windows 10。这个库只包含 POCO 类。
我有另一个名为 "Communications" 的项目,目标是 .net 4.6 并引用可移植库:
当我尝试构建项目时,我收到警告:
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.0\bin\Microsoft.Common.CurrentVersion.targets
Line 1819
详细的构建日志在这里:buildlog.txt
为什么我会收到此警告?如何摆脱它?
以下是构建日志中可能相关的部分:
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
我在我的 .net 4.6 项目中更新了 nuget 包 System.Net.Http,警告消失了。 通常,很难找到此类问题的根源。通过 nugget 分发的 .NET 将来会一团糟。