生成项目时,我收到烦人的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,以防有用的信息。

最佳答案

此问题的原因是StrongGrid包的创作不正确。
0.30StrongGrid版本是针对3.1.0Pathoschild.Http.FluentClient版本构建的,但是其用于创建NuGet软件包的.nuspec文件仍将3.0.0版本作为依赖项,因此使用方项目将获取较旧的版本,从而产生了无法解决的冲突。

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

10-07 21:12