问题
Working in VS2017 I have a C# project .Net 4.6 using several Nuget packages. On my dev machine from within VS it builds just fine, I've tested it will restore Nuget packages from completely clean and build correctly.
On our build machine it is build using MSBuild.exe and now everything is going wrong.
Build>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe" ".sln" /p:Configuration="Release" /p:Platform="Any CPU" /p:version=4.2.0.3230 /m " Microsoft (R) Build Engine version 15.7.179.6572 for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved.
I can see the /packages sub-dir is getting populated as expected with packages but then I get errors like:
Encountered conflict between 'Reference:System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL' and 'Platform:System.Numerics.Vectors.dll'. Could not determine winner because 'Reference:System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL' does not exist. Encountered conflict between 'Platform:System.Numerics.Vectors.dll' and 'Reference:System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL'. Could not determine winner because 'Reference:System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL' does not exist.
My project file looks like:
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [] For SearchPath "{HintPathFromItem}". Considered "packages\log4net.2.0.8\lib\net45-full\log4net.dll", but it didn't exist.
I mean, here it is:
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
</Reference>
Every build is a completely clean build (it's wiped between) so I can clearly see Nuget has downloaded log4net.dll
I am getting loads of these and I cannot see any explanation why, or where to start looking for a solution. Everything looks to be where it should be
回答1:
You can try changing a binding redirect in your config file to 2.8.0 of log4net
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.8.0" newVersion="2.0.8.0" />
来源:https://stackoverflow.com/questions/62780419/msbuild-exe-gives-errors-about-nuget-package-conflicts-what-does-it-mean