我在构建中收到类似于以下内容的警告墙:
No way to resolve conflict between "Newtonsoft.Json, Version=7.0.0.0"
and "Newtonsoft.Json, Version=6.0.0.0".
Choosing "Newtonsoft.Json, Version=7.0.0.0" arbitrarily.
我收到以下 dll 的附加警告(有意重复):
Microsoft.Owin
System.Web.Http
Newtonsoft.Json
System.Net.Http.Formatting
Microsoft.Owin
Microsoft.ApplicationInsights
以及每个警告的匹配消息:
Consider app.config remapping of assembly to solve conflict and get rid of warning.
最后,我得到了这个冲突:
Microsoft.Common.CurrentVersion.targets Found conflicts between
different versions of the same dependent assembly.
Please set the "AutoGenerateBindingRedirects" property to true
in the project file.
我已经阅读了我能找到的关于这些消息的所有堆栈溢出和 MSDN 答案。根据这个答案 https://stackoverflow.com/questions/37345466/c-sharp-no-way-to-resolve-conflict-between-x-and-y,最好的解决方案是更改导致冲突警告的引用以引用相同版本。问题似乎在于,来自解决方案中 53 个项目中的一些程序集的程序集依赖于具有不同版本的不同程序集。我无法判断哪些项目导致这些警告,并且绑定重定向(我检查过,在每个项目中自动生成)对警告没有影响。
我该如何解决这些构建警告?
它们都是相同的警告,实际上是在告诉您该怎么做。您可以清理项目中的所有引用。如果您使用 NuGet,这应该不是什么大问题。进入管理 NuGet 包。您应该在列表中看到重复的包。将旧包的引用移至新版本的包。这是解决冲突的一种方法。
第二种方法是为所有冲突的程序集添加绑定重定向。以下是 Json.net 重定向的示例。
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)