NuGet resolves invalid package dependency version

So, I have the NServiceBus.Host package, which depends on NServiceBus> = 4.5.0.

Nuget has a version of NServiceBus version 4.5.1. When I install the NServiceBus.Host package, I get:

PM> install-package nservicebus.host Attempting to resolve dependency 'NServiceBus (β‰₯ 4.5.0)'. Attempting to resolve dependency 'NServiceBus.Interfaces (β‰₯ 4.5.0)'. Installing 'NServiceBus.Interfaces 4.5.0'. You are downloading NServiceBus.Interfaces from NServiceBus Ltd, the license agreement to which is available at http://particular.net/LicenseAgreement. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device. Successfully installed 'NServiceBus.Interfaces 4.5.0'. Installing 'NServiceBus 4.5.0'. 

As you can see, I get the dependency version version 4.5.0.

The nuget doco says:

If the dependency is not installed, NuGet goes through the following steps:

NuGet lists each version of Subkismet in the feed, which is within the specification of the version. NuGet then narrows this value only for packages with the smallest version of Major / Minor. From the remaining packages, NuGet selects the number with the highest version number.

"NuGet selects the number with the highest version number." seems to be broken here, as the version is missing.

Is this a bug in NuGet?

+6
source share
2 answers

The NuGet dependency resolution documentation you are referring to has not been updated since December 2010. These NuGet docs are available here: https://docs.nuget.org

In addition, NuGet will - by default - allow the lowest version of major.minor within the allowable range, as defined in the package dependencies. Therefore, 4.5.0 is the correct default resolution.

New since NuGet v2.8.1: you can use an alternative dependency resolution algorithm using the NuGet package manager console:

Installation package NServiceBus.Host -DependencyVersion HighestPatch

There are more options, check out the docs here: https://docs.nuget.org/docs/reference/package-manager-console-powershell-reference#Install-Package

+9
source

As Xavier said, this is similar to the default behavior. However, the documentation states that you can change the default behavior by editing the nuget configuration:

Defines the version of the dependency package to be selected from the list of valid dependency packages. The default value is the lowest. You can override this default value by specifying the new default value in the nuget.config file:

 <configuration> <config> <add key="DependencyVersion" value="HighestPatch" /> </config> </configuration> 

I edited my configuration file as described in the documentation:

 %AppData%\Nuget\NuGet.Config 

Then it works in Powershell, but NOT on the regular command line.

The docs also say:

It is strange that the docs indicate that pre 2.7.2 was HighestPatch by default ...

Note that for NuGet 2.7.2 or earlier, the default value is HighestPatch and cannot be changed.

The release notes for 2.8 mention behavior changes and the reason the installation package now has a consistent result of resolving dependencies over time.

https://docs.nuget.org/docs/release-notes/nuget-2.8

+3
source

All Articles