How to specify a specific version of dependencies in nuspec?

I am creating my first nuget package. I added a dependency on a version that is not the latest version. However, I do not want to update the latest version of this dependency. Can I instruct him to use a specific version?

<dependencies> <dependency id="NHibernate" version="3.2.0.3001" /> </dependencies> 

When I install the package, I see the following:

 Attempting to resolve dependency 'NHibernate (≥ 3.2.0.3001)'. 

This creates the following when I install the package.

 <packages> <package id="Iesi.Collections" version="3.2.0.4000" /> <package id="NHibernate" version="3.2.0.4000" /> </packages> 

I would really like to see something like this: An attempt to resolve the dependency "NHibernate (3.2.0.3001)".

+64
nuget nuget-package
Oct. 14 '11 at 19:02
source share
4 answers

You should be able to force the exact version using brackets:

 <dependency id="NHibernate" version="[3.2.0.3001]" /> 

Full details of the formats you can use are on the NuGet website, here:

http://docs.nuget.org/docs/reference/version-range-specification

+92
Oct. 15 '11 at 10:49
source share

From the NuGet docs website , complete notation:

enter image description here

+4
Apr 04 '17 at 8:55
source share

On the user side, you can also restrict the update by specifying allowVersions in the packages.config file. http://docs.nuget.org/docs/reference/versioning#Constraining_Upgrades_To_Allowed_Versions

+2
Dec 23 2018-11-23T00:
source share

According to http://nuget.codeplex.com/wikipage?title=Dependency%20Resolution and other sources just specifying the lower bound as

 <dependencies> <dependency id="NHibernate" version="3.2.0.3001" /> </dependencies> 

will result in the highest fix / fix level for the youngest version of the major / minor version corresponding to that version.

If I do not fully understand the documentation, this will be consistent with the highest version 3.2. *, but not version 3.3. * or more if version 3.2 is not found. *.

If there is a reason 3.2.0.3001 is the only version you want to depend on, you may find that your package is incompatible with other packages that also depend on NHibernate, for example, because another package depends on NHibernate [3.2.0.3002 , 3.3), which means at least 3.2.0.3002, but below 3.3.

+2
Aug 29 '14 at 8:44
source share



All Articles