如何诊断警告 MSB3277:发现无法解决的同一依赖程序集的不同版本之间存在冲突 [英] How to diagnose warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved

查看:67
本文介绍了如何诊断警告 MSB3277:发现无法解决的同一依赖程序集的不同版本之间存在冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在构建项目时收到令人讨厌的 MSB3277 警告.我将详细程度增加到详细",并且能够从日志中获取以下信息:

I'm getting an annoying MSB3277 warning when I build my project. I increased verbosity to "detailed" and I was able to get the following information from the log:

      There was a conflict between "Pathoschild.Http.Client, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null" and "Pathoschild.Http.Client, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null".
         "Pathoschild.Http.Client, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null" was chosen because it was primary and "Pathoschild.Http.Client, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null" was not.

         References which depend on "Pathoschild.Http.Client, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null" [C:\Users\desau\.nuget\packages\pathoschild.http.fluentclient\3.0.0\lib\netstandard1.3\Pathoschild.Http.Client.dll].
             C:\Users\desau\.nuget\packages\pathoschild.http.fluentclient\3.0.0\lib\netstandard1.3\Pathoschild.Http.Client.dll
               Project file item includes which caused reference "C:\Users\desau\.nuget\packages\pathoschild.http.fluentclient\3.0.0\lib\netstandard1.3\Pathoschild.Http.Client.dll".
                 C:\Users\desau\.nuget\packages\pathoschild.http.fluentclient\3.0.0\lib\netstandard1.3\Pathoschild.Http.Client.dll

         References which depend on "Pathoschild.Http.Client, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null" [].
             C:\Users\desau\.nuget\packages\stronggrid\0.30.0\lib\netstandard1.3\StrongGrid.dll
               Project file item includes which caused reference "C:\Users\desau\.nuget\packages\stronggrid\0.30.0\lib\netstandard1.3\StrongGrid.dll".
                 C:\Users\desau\.nuget\packages\stronggrid\0.30.0\lib\netstandard1.3\StrongGrid.dll

如果我正确理解了这个日志,它告诉我我的项目引用了Pathoschild.Http.Client 3.0 版和3.1 版.我理解对 3.1 版的引用,因为我的项目引用了一个名为 StrongGrid 的 nuget 包,它本身引用了 Pathoschild 3.1 版

If I understand this log correctly, it's telling me that my project references Pathoschild.Http.Client version 3.0 and also version 3.1. I understand the reference to version 3.1 because my project references a nuget package called StrongGrid which itself references Pathoschild version 3.1

但我不明白对 3.0 版的引用从何而来.

But I fail to understand where the reference to version 3.0 comes from.

我正在使用 Visual Studio 2017 和 MSBuild 15,以防万一这是有用的信息.

I'm using Visual Studio 2017 and MSBuild 15 in case that's helpful information.

推荐答案

此问题的原因是 StrongGrid 包的编写不正确.

The reason for this issue is that the StrongGrid package is authored incorrectly.

StrongGrid0.30 版本是针对 Pathoschild.Http.FluentClient3.1.0 版本构建的,但是他们用于创建 NuGet 包的 .nuspec 文件仍然将版本 3.0.0 列为依赖项,因此消费项目将获取旧版本,从而产生无法解决的冲突已解决.

The version 0.30 of StrongGrid is built against version 3.1.0 of Pathoschild.Http.FluentClient, but their .nuspec file used for creating the NuGet package still lists version 3.0.0 as dependency, so the consuming project will fetch an older version, creating a conflict that cannot be resolved.

要解决此问题,您可以通过添加对 csproj 文件的包引用来覆盖版本来显式引用 Pathoschild.Http.FluentClient 的版本 3.1.0.

To work around this problem, you can explicitly reference version 3.1.0 of Pathoschild.Http.FluentClient by adding a package reference to the csproj file to override the version.

这篇关于如何诊断警告 MSB3277:发现无法解决的同一依赖程序集的不同版本之间存在冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆