Search Unity

Can't build Unity projects: Multiple assemblies with equivalent identity have been imported

Discussion in 'Asset Importing & Exporting' started by vs-cby, Mar 28, 2018.

  1. vs-cby

    vs-cby

    Joined:
    Jun 23, 2017
    Posts:
    5
    Hi,

    We've just upgraded from 2017.3 to 2018.1 Beta.
    We are running into next problem now.
    In VS Tools for Unity (3.4 on VS2015) the Unity projects do not want to build anymore:

    Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files\Unity\Editor\Data\MonoBleedingEdge\lib\mono\4.7.1-api\Facades\System.Xml.XmlSerializer.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\Facades\System.Xml.XmlSerializer.dll'. Remove one of the duplicate references. UnityEditor.StandardEvents

    and the same error for many more of these System.xxx.dll assemblies.
    The Unity projects target .NET framework 4.6, just like the other self-made business assemblies that we put under the Plugins folder.

    In the Unity.csproj files, I notice that some references are indeed duplicated:

       <Reference Include="mscorlib">
    <HintPath>C:\Program Files\Unity\Editor\Data\MonoBleedingEdge\lib\mono\4.6-api\mscorlib.dll</HintPath>
    </Reference>
    ...
    <Reference Include="mscorlib">
    <HintPath>C:\Program Files\Unity\Editor\Data\MonoBleedingEdge\lib\mono\4.7.1-api\mscorlib.dll</HintPath>
    </Reference>


    However, there are more build errors listed than duplicates found in the .csproj
    Removing the duplicate references does not help, and next time when re-opening the Unity projects the duplicate references are back again.

    Anyone an idea what is going on?
    Thanks a lot.
     
  2. IgorAherne

    IgorAherne

    Joined:
    May 15, 2013
    Posts:
    393
    Filed a bug report, case number 1020752
     
    Last edited: Apr 1, 2018
    LeonhardP likes this.
  3. recursive

    recursive

    Joined:
    Jul 12, 2012
    Posts:
    669
    You should probably edit your post to just the case number and remove the link. If you post a link to the fogbugz page, someone can see ALL of your bug reports, which could contain project data that could conceivably be under NDA (like console stuff).
     
    IgorAherne likes this.
  4. lukaszunity

    lukaszunity

    Administrator

    Joined:
    Jun 11, 2014
    Posts:
    461
  5. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
  6. VladAdGad

    VladAdGad

    Joined:
    Nov 19, 2017
    Posts:
    1
    I have "student" solution for that.
    Go to inside 'C:\Program Files\Unity\Editor\Data\MonoBleedingEdge\lib\mono\4.7.1-api\Facades\*' then create BackUp Folder and put(not copy) all .*dll into this folder. Then delete all .*sln solutions and open Project in Unity. Build Succeeded
     
  7. sailro

    sailro

    Microsoft

    Joined:
    Jul 30, 2014
    Posts:
    167
    Hello,

    This should be fixed shortly in Unity. In fact this is related to the way Unity is compiling projects targeting .NET Standard.

    As a workaround, you can add the following script in an **Editor** folder, to patch the project generation:

    Code (CSharp):
    1.  
    2. using System.IO;
    3. using System.Linq;
    4. using System.Text;
    5. using System.Xml.Linq;
    6.  
    7. using UnityEditor;
    8.  
    9. #if ENABLE_VSTU
    10.  
    11. using SyntaxTree.VisualStudio.Unity.Bridge;
    12.  
    13. [InitializeOnLoad]
    14. public class ProjectFileHook
    15. {
    16.    // necessary for XLinq to save the xml project file in utf8
    17.    class Utf8StringWriter : StringWriter
    18.    {
    19.        public override Encoding Encoding
    20.        {
    21.            get { return Encoding.UTF8; }
    22.        }
    23.    }
    24.  
    25.    static ProjectFileHook()
    26.    {
    27.        ProjectFilesGenerator.ProjectFileGeneration += (string name, string content) =>
    28.        {
    29.            // parse the document and make some changes
    30.            var document = XDocument.Parse(content);
    31.            var ns = document.Root.Name.Namespace;
    32.  
    33.            document.Root
    34.                .Descendants()
    35.                .First(x => x.Name.LocalName == "PropertyGroup")
    36.                .Add(new XElement(ns + "ImplicitlyExpandNETStandardFacades", "false"),
    37.                     new XElement(ns + "ImplicitlyExpandDesignTimeFacades", "false"));
    38.  
    39.            // save the changes using the Utf8StringWriter
    40.            var str = new Utf8StringWriter();
    41.            document.Save(str);
    42.  
    43.            return str.ToString();
    44.        };
    45.    }
    46. }
    47.  
    48. #endif
    Regards
    Sebastien Lebreton [MSFT]
     
    Last edited: May 22, 2018
    WallyCZ, Grizmu, skycc and 1 other person like this.
  8. DerickTP

    DerickTP

    Joined:
    Jul 28, 2014
    Posts:
    8
    Thank you, Thank you very much !!!!
     
  9. kwcae

    kwcae

    Joined:
    May 26, 2017
    Posts:
    34
    This appears to be back in the 2018.2.0f2 build of unity again.
     
  10. rafaga

    rafaga

    Joined:
    Mar 20, 2009
    Posts:
    4
    And in version 2018.3 as well.
     
    SortOth likes this.
  11. Disastercake

    Disastercake

    Joined:
    Apr 7, 2012
    Posts:
    317
    Came up in 2018.3 for me. For some reason I had a few System .dll files in my base Assets directory. I must have put them there in the past to fix a bug I've since forgotten about. It appears these .dll files now come with the base engine package. Removing them from my project / asset directory fixed the problem for me and didn't seem to cause any erroneous after effects.

    Specifically they were:
    System.Configuration.dll
    System.Data.dll
    System.EnterpriseServices.dll
    System.Security.dll
     
    VaporAnomaly and mickeyband like this.
  12. Glader

    Glader

    Joined:
    Aug 19, 2013
    Posts:
    456
    Encountering this issue in 2018.4 still. @sailro 's suggested workdaround did not work for me because I generate builds external from Unity3D and auto-import the generated assemblies. This is preventing me from using .NET Standard 2.0 Azure Service Bus library from within Unity3D.

    Problematic assemblies are:
    System.Runtime.Serialization.Json.dll
    System.Runtime.Numerics.dll
    System.Security.Principal.dll
     
    Last edited: Oct 30, 2019