SpruceMoose
SpruceMoose

Reputation: 10320

NuGet Package Reference Versioning and VS Package Manager

I have been setting the package references in my .csproj files to accept any minor version of dependent NuGet packages (see NuGet Package Versioning reference examples). An example of this might be as per the below:

<!-- Accepts any 6.2.x version. -->
<PackageReference Include="ExamplePackage" Version="6.2.*" />

However, whilst this appears to work (i.e. the latest release version of 6.2.2 is restored), the NuGet package manager GUI built into Visual Studio appears to read the package reference as 6.2.0 and prompts me to upgrade to 6.2.2. Performing a restore from the command line appears to download 6.2.2 but I cannot get the VS Package Manager to play ball.

Is there any way to get the VS Nuget Package Manager GUI to accept that 6.2.2 is what has actually been restored?

Upvotes: 2

Views: 677

Answers (1)

Leo Liu
Leo Liu

Reputation: 76928

However, whilst this appears to work (i.e. the latest release version of 6.2.2 is restored), the NuGet package manager GUI built into Visual Studio appears to read the package reference as 6.2.0 and prompts me to upgrade to 6.2.2

This is a known issue about the PackageReference versioning with wildcard.

It seems use a wildcard * is the correct way for NuGet Restore to float to a higher version. However, the NuGet package manager GUI still takes the lowest version. The current workaround is update the nuget package to the latest version via NuGet package manager GUI, but this way will remove the wildcard *.

For tracking this NuGet issue, I recommend that you vote on and follow the earlier reported issue for updates and fix notifications:

https://github.com/NuGet/Home/issues/3788

Hope this helps.

Upvotes: 2

Related Questions