简体   繁体   中英

MSBuild.exe gives errors about Nuget package conflicts, what does it mean?

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

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" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM