Kris Harper
Kris Harper

Reputation: 5862

Multiple assembly conflict with NuGet System references

I have a project that references this NuGet package. The package has several framework references (e.g., System.Collections). My project is targeting .NET Framework 4.6.2, and I have the .NET 4.6.2 targeting pack installed on my build machine.

When I install the NuGet package in Visual studio, it also installs dependencies for all the framework packages, so my packages.config ends up looking like this

<packages>
  <package id="CommandLineParser" version="2.3.0" targetFramework="net462" />
  <package id="System.Collections" version="4.3.0" targetFramework="net462" />
  <package id="System.Console" version="4.0.0" targetFramework="net462" />
  <package id="System.Diagnostics.Debug" version="4.0.11" targetFramework="net462" />
  <package id="System.Globalization" version="4.0.11" targetFramework="net462" />
  <package id="System.IO" version="4.1.0" targetFramework="net462" />
  <package id="System.Linq" version="4.1.0" targetFramework="net462" />
  <package id="System.Linq.Expressions" version="4.1.0" targetFramework="net462" />
  <package id="System.Reflection" version="4.1.0" targetFramework="net462" />
  <package id="System.Reflection.Extensions" version="4.0.1" targetFramework="net462" />
  <package id="System.Reflection.TypeExtensions" version="4.1.0" targetFramework="net462" />
  <package id="System.Resources.ResourceManager" version="4.0.1" targetFramework="net462" />
  <package id="System.Runtime" version="4.1.0" targetFramework="net462" />
  <package id="System.Runtime.Extensions" version="4.1.0" targetFramework="net462" />
</packages>

I've read that this is because the package targets .NET Standard, which will automatically import all these packages even if they are present on the machine.

So far, everything is fine, and I can build the project on my machine. However, on the build server, I get the following error

CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Jenkins\jobs\MyProject\workspace\packages\System.Runtime.Extensions.4.1.0\lib\net462\System.Runtime.Extensions.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.2\Facades\System.Runtime.Extensions.dll'. Remove one of the duplicate references.

The build server also has the .NET 4.6.2 targeting pack installed. Moreover, on my dev machine, I also have the file

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.Runtime.Extensions.dll

as well as all the other facade system files.

So my question is, why does this fail on my build server? It seems like all the same versions of .NET are installed, and I'm not sure what else to check.

Upvotes: 1

Views: 508

Answers (1)

Kris Harper
Kris Harper

Reputation: 5862

I installed Visual Studio 2015 Update 3 on the build server, and now the project builds without issue. I'm not totally sure what the change was that fixed the error, unfortunately.

Upvotes: 0

Related Questions