如何管理重复的程序集引用 C# Unity / 如何使用标志编译 C# 项目

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

我正在尝试将 RosSharp (https://github.com/siemens/ros-sharp) 和混合现实工具包集成到一个 Unity 项目中。然而,这两个库都使用 Newtonsoft.Json 导致错误:

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)

删除其中一个 DLL 将导致许多其他错误。

通过开发人员文档查找此错误 (https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs1703):建议我使用以下标志编译项目:/t:library /out:.\bin2\cs1703.dll /keyfile:key.snk

如何使用特定标志在 Visual 中编译 C# 解决方案。

我相信这个问题也可以使用外部别名来解决,尽管我不知道它们是如何实现的。

事实证明,我需要使用正确的 Unity 版本 - 2017 和(在我的例子中是 2017.4.16),在 Visual Studio 中,我还需要转到项目 > 管理 NuGet 包并更新我的Newtonsoft 软件包。