10

I have a confusing issue with Nuget. I have a number of projects who claim to have System.Collections.Immutable installed at version 1.3.0 but if I look at the version of the dll in all the references I see version 1.2.1.0

When I open up the DLL with JustDecompile I see enter image description here which declares that the DLL version is indeed 1.2.1.0 but has been installed in directory packages\System.Collections.Immutable.1.3.0

A typical packages.config file will contain

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

and the csproj is

<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>

If I try to open the downloaded nuget package from the gallery and open with nuget package explorer I get

enter image description here

bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217
  • 1
    I started facing this issue when I added `OrderBy` on list of anonymous types, however installing `System.Collections.Immutable` package from nuget resolved the error. – Anil Jan 19 '18 at 12:56

2 Answers2

3

The NuGet package version and the assembly version are not necessarily the same. There is no restriction on what versions are used in either.

So looking at System.Collections.Immutable 1.3.0 the assembly version is 1.2.1.0 for the assemblies in the NuGet package.

If you cannot open the NuGet package in the NuGet Package Explorer you can open it in a zip file application such as 7-zip. Or just rename the file to .zip and open it with the built-in Windows zip file extractor.

Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • The previous version of the library and nuget package were both 1.2.0 and then the library got promotoed to 1.2.1 and the nuget package to 1.3.0. I agree that in theory they don't need to match up but this smells. A random sampling of previous nuget versions of the same package have the assembly version and the nuget version matching. – bradgonesurfing Dec 21 '16 at 08:20
  • I added an issue at corefx asking for an explanation. https://github.com/dotnet/corefx/issues/14640 – bradgonesurfing Dec 21 '16 at 08:21
1

Got the same problem recently. System.Collections.Immutable is a multi-target package, so the version of the assembly imported to your solution depends on the target. For instance, if you are in a .Net Framework project, this is the file stored in portable-net45+win8+wp8+wpa81 that will be used, hence the different version.

nunop
  • 2,036
  • 2
  • 20
  • 36