如何诊断警告MSB3277:发现无法解决的同一依赖程序集不同版本之间的冲突。

8

当我构建我的项目时,我收到了一个令人烦恼的MSB3277警告。我将详细程度增加到“详细”并能够从日志中获取以下信息:

      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 两个版本。因为我的项目引用了一个名为 StrongGrid 的 nuget 包,而 StrongGrid 引用了 Pathoschild 3.1 版本,所以我能理解对 3.1 版本的引用。

但是我不明白对于 3.0 版本的引用来自哪里。

如果有帮助信息的话,我使用的是 Visual Studio 2017 和 MSBuild 15。


你是否正在使用VS 2017版本15.3和.NET Core SDK 2.0.0?(在八月发布)-它们应该包含必要的冲突解决逻辑。 - Martin Ullrich
VS 2017 版本 15.3.5,从命令提示符构建时,只会显示“使用工具版本“15.0”进行构建”。 - desautelsj
据我所知,我只引用了一个NuGet包,它引用了Pathoschild.Http.Client版本3.1。我没有看到对版本3.0的引用,并且日志中没有命名第二个包(除非我没有正确阅读日志)。 - desautelsj
通过NuGet包管理器升级pathoschild.http.fluentclient3.1.0是否有帮助? - Martin Ullrich
让我们在聊天中继续这个讨论 - desautelsj
显示剩余2条评论
1个回答

7
这个问题的原因是StrongGrid包不正确。版本0.30StrongGrid基于Pathoschild.Http.FluentClient的版本3.1.0构建,但它们用于创建NuGet包的.nuspec文件仍将版本3.0.0列为依赖项,所以使用该包的项目会获取旧版本,从而创建无法解决的冲突。要解决此问题,您可以通过向csproj文件添加软件包引用来覆盖版本,明确引用Pathoschild.Http.FluentClient的版本3.1.0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接