【问题标题】:How to diagnose warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved如何诊断警告 MSB3277:发现同一依赖程序集的不同版本之间存在无法解决的冲突
【发布时间】:2018-03-16 02:56:20
【问题描述】:

我在构建项目时收到了令人讨厌的 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 版。我理解对 3.1 版的引用,因为我的项目引用了一个名为 StrongGrid 的 nuget 包,该包本身引用了 Pathoschild 3.1 版

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

我正在使用 Visual Studio 2017 和 MSBuild 15,以防提供有用的信息。

【问题讨论】:

  • 您使用的是 VS 2017 版本 15.3 和 .NET Core SDK 2.0.0 吗? (8 月发布)- 它们应该包含必要的冲突解决逻辑
  • VS 2017 版本 15.3.5 和从命令提示符构建时,它只是说 Building with tools version "15.0"
  • 运行dotnet --info:.NET Command Line Tools (2.0.0)
  • 抱歉,我刚刚阅读了Http.Client 并认为这是目前 netstasndard 库的反复出现的问题。这是一个不同的库和两个 NuGet 包,具体取决于同一程序集的不同版本。
  • 据我所知,我只引用了一个引用 Pathoschild.Http.Client 3.1 版的 nuget 包我看不到对 3.0 版的引用在哪里,日志也没有命名第二个包(除非我没有正确阅读日志)。

标签: c# visual-studio msbuild


【解决方案1】:

此问题的原因是 StrongGrid 包的创作不正确。

StrongGrid 的版本 0.30 是针对 Pathoschild.Http.FluentClient 的版本 3.1.0 构建的,但它们用于创建 NuGet 包的 .nuspec 文件仍将版本 3.0.0 列为依赖项,因此使用项目将获取旧版本,造成无法解决的冲突。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-09-06
    • 2014-09-06
    • 1970-01-01
    • 2014-06-26
    • 2010-12-24
    • 2018-02-25
    相关资源
    最近更新 更多