Reputation: 831
On the same code branch we are successfully building on one machine, but on another we get this:
Error Multiple assemblies with equivalent identity have been imported: '...\src\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.2\Facades\System.Xml.ReaderWriter.dll'. Remove one of the duplicate references.
How can we resolve?
Upvotes: 9
Views: 14351
Reputation: 312
I was able to resolve the issue by updating the NuGet package Microsoft.Net.Compilers to a newer version. It had been at 1.0.0, which I believe wasn't using the newer version of MSBuild (as pointed out in some of the other answers).
Upvotes: 0
Reputation: 1
Delete the dll in 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.2\Facades\System.Xml.ReaderWriter.dll'. and build your code.
Add it back after build successfully.
Upvotes: 0
Reputation: 1732
Made the following change to .csproj, which did the trick:
<PackageReference Include="System.Reflection.Emit">
<Version>4.3.0</Version>
<ExcludeAssets>All</ExcludeAssets>
<IncludeAssets>none</IncludeAssets>
</PackageReference>
Upvotes: 1
Reputation: 1270
See https://github.com/dotnet/corefx/issues/14050
This explains that in v4.3.0 of the nuget package it requires using VS 2015 Build tools Update 3 or later.
If you can't upgrade, downgrade the package to v4.0.11.
Upvotes: 1
Reputation: 1623
In case someone comes looking for another answer. Can happen (6/6/2018) due to a package reinstall ambiguity between matching namespaces of NetStandard and .NET Framework.
Issue took root updating a NetStandard 3rd party package and it required/installed a dependency of System.Net.NetworkInformation
(v4.3.0 I believe.) Honestly worked fine before that package so I manually removed the dependency from CSPROJ and package.config that main solution added.
It's not clean but demonstrates a NuGet or MSBuild issue not recognizing they are in fact different assemblies and thus count as a duplicate reference.
Upvotes: 0
Reputation: 2091
Using MSBuild 15 solves the problem. MSBuild 15 is part of the .NET Core SDK or can be downloaded using the Build Tools for Visual Studio 2017.
Upvotes: 5
Reputation: 11
Solved the "Error Multiple assemblies" problem by uninstalling Xamarin from computer and Visual Studio 15.
Followed this instruction: https://developer.xamarin.com/guides/cross-platform/getting_started/visual_studio_with_xamarin/troubleshooting/uninstall-xamarinvs/
My problem occured when updating asp.net nuget packages from version 1.0.0 to 1.1.0.
Upvotes: 1
Reputation: 95482
I suspect that you have both a directly referenced (via the GAC or file system via Browse...) dll and a Nuget package in your project.
Best to try uninstalling the Nuget package, and then check your references and uncheck any remaining references to System.Xml.ReaderWriter.dll
, and then install your Nuget reference again.
UPDATE
For reference, a similar error was encountered with System.Threading
when an EntityFramework package was renamed. Perhaps one of your packages has a newer version or has a renamed namespace? Or maybe you have incompatible versions of .NET Standard?
Upvotes: 1