【问题标题】:Nuget seems to install the wrong version of System.Collections.ImmutableNuget 似乎安装了错误版本的 System.Collections.Immutable
【发布时间】:2016-12-20 14:03:34
【问题描述】:

我对 Nuget 有一个令人困惑的问题。我有许多项目声称在 1.3.0 版本中安装了 System.Collections.Immutable,但如果我查看所有参考资料中的 dll 版本,我会看到版本 1.2。 1.0

当我用 JustDecompile 打开 DLL 时,我看到 它声明 DLL 版本确实是 1.2.1.0 但已安装在目录 packages\System.Collections.Immutable.1.3.0

一个典型的 packages.config 文件将包含

<package id="System.Collections.Immutable" version="1.3.0" targetFramework="net452" />

而csproj是

<Reference 
  Include="System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
     <HintPath>$(SolutionDir)packages\System.Collections.Immutable.1.3.0\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
  <Private>True</Private>
</Reference>

如果我尝试从库中打开下载的 nuget 包并使用 nuget 包资源管理器打开,我会得到

【问题讨论】:

  • 当我在匿名类型列表中添加 OrderBy 时,我开始遇到这个问题,但是从 nuget 安装 System.Collections.Immutable 包解决了该错误。

标签: c# nuget immutable-collections


【解决方案1】:

NuGet 包版本和程序集版本不一定相同。两者中使用的版本都没有限制。

所以查看 System.Collections.Immutable 1.3.0,NuGet 包中的程序集的程序集版本是 1.2.1.0。

如果您无法在 NuGet 包资源管理器中打开 NuGet 包,您可以在 7-zip 等 zip 文件应用程序中打开它。或者只是将文件重命名为 .zip 并使用内置的 Windows zip 文件提取器打开它。

【讨论】:

  • 库和nuget包的以前版本都是1.2.0,然后库升级到1.2.1,nuget包升级到1.3.0。我同意理论上它们不需要匹配,但是这闻起来很臭。同一包的先前 nuget 版本的随机抽样具有程序集版本和 nuget 版本匹配。
  • 我在 corefx 添加了一个问题,要求解释。 github.com/dotnet/corefx/issues/14640
【解决方案2】:

最近遇到了同样的问题。 System.Collections.Immutable 是一个多目标包,因此导入到您的解决方案的程序集版本取决于目标。例如,如果您在 .Net Framework 项目中,则将使用存储在 portable-net45+win8+wp8+wpa81 中的文件,因此版本不同。

【讨论】:

    猜你喜欢
    • 2021-02-21
    • 1970-01-01
    • 1970-01-01
    • 2018-03-18
    • 2016-03-17
    • 1970-01-01
    • 1970-01-01
    • 2022-11-24
    • 1970-01-01
    相关资源
    最近更新 更多