Quality Catalyst
Quality Catalyst

Reputation: 6795

Error CS1703: Multiple assemblies with equivalent identity have been imported - Xamarin + VSTS

I upgraded to the latest Xamarin for Visual Studio 2015 (Community Edition), recompiled my projects, checked in a few small code changes and my VSTS build server fails with this error message:

[error]CSC(0,0): Error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll' and 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll'. Remove one of the duplicate references.

Internet searches return nearly no details about this issue in general and no valuable information at all in the context of VSTS and Xamarin.

The only code change that I consider to be relevant to the issue was done by Visual Studio in the project file:

enter image description here

I only develop for Android, am on Xamarin 4.2 and use the JDK 8 u101.

Any idea how to solve this issue?

Upvotes: 30

Views: 49582

Answers (8)

Adil H. Raza
Adil H. Raza

Reputation: 1701

One of the referenced projects had a package reference Microsoft.NETCore.Portable.Compatibility. I removed it and Android and iOS projects built successfully again.

Upvotes: 1

Dr TJ
Dr TJ

Reputation: 3356

In my case I had the following line (PackOnBuild) in my csproj file.

<PropertyGroup>
   <!-- some other properties -->
   <PackOnBuild>true</PackOnBuild>
   <!-- some other properties -->
<PropertyGroup>

Setting the PackOnBuild to False fixed the issue for me:

<PropertyGroup>
   <!-- some other properties -->
   <PackOnBuild>false</PackOnBuild>
   <!-- some other properties -->
<PropertyGroup>
 

Upvotes: 0

1iveowl
1iveowl

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: 11

hormberg
hormberg

Reputation: 181

I had a similar issue.

the following error was in the jenkins console output

Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\Jenkins\jobs\...\lib\net461\System.ComponentModel.Annotations.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\System.ComponentModel.Annotations.dll'. 
Remove one of the duplicate references.

I removed the duplicate reference in one of my projects and it worked.

Upvotes: 1

Ovidiu Caba
Ovidiu Caba

Reputation: 31

I updated all Microsoft packages and the compiler error went away. So I believe that the general solution for this kind of compiler errors consist in two steps:

  1. Upgrade the involved NuGet package;
  2. If the 1st step is not sufficient, upgrade all Microsoft NuGet packages.

Upvotes: 1

Adri&#225;n Romero
Adri&#225;n Romero

Reputation: 620

I fixed this for myself by changing 7.1 back down to 6.0, and compilation started working again. The problem only appears on my compilation agent:

Compilation settings

Upvotes: 2

DriLLFreAK100
DriLLFreAK100

Reputation: 1606

I have just solved the issue. Try removing the mscorlib.dll from the References Folder inside your solution itself. Refer to the below highlighted folder (Reference Folder). It seems that Xamarin will include the mscorlib.dll by default during its build. Hope it helps :)

enter image description here

Upvotes: 38

David Faivre
David Faivre

Reputation: 2342

I had an error installing a .net core nuget, which explicitly installs all the System.* libraries. It turned out that my Microsoft.Net.Compilers package needed upgrading, then this error went away.

Upvotes: 4

Related Questions