How to manage duplicate assembly references C# Unity / How to compile C# project with flags

1.6k views Asked by At

I am trying integrate RosSharp (https://github.com/siemens/ros-sharp) and Mixed Reality Toolkit into one Unity project. Both of these libraries however use Newtonsoft.Json which causes the error:

error CS1703: An assembly `Newtonsoft.Json' with the same identity has already 
been imported. Consider removing one of the references
Assets/HoloToolkit/Utilities/Scripts/GLTF/Plugins/JsonNet/Newtonsoft.Json.dll 
(Location of the symbol related to previous error)
Assets/RosSharp/Plugins/Newtonsoft.Json.dll (Location of the symbol related to 
previous error)

Deleting one of these DLL's will cause lots of other errors.

Looking up this error through developer documentation (https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs1703): I am advised to compile the project with the following flags: /t:library /out:.\bin2\cs1703.dll /keyfile:key.snk.

How do you compile a C# solution in Visual with specific flags.

I believe this issue could also possibly be addressed using extern aliases, although I do not know how those are implemented.

1

There are 1 answers

0
Enrique Avina On BEST ANSWER

It turns out, I needed to use the right Unity Version - 2017 and (2017.4.16 in my case) and in Visual Studio, I also needed to go to Project > Manage NuGet packages and update my Newtonsoft package.