How to create a nuspec dependency which includes prereleases

Filip De Vos picture Filip De Vos · Feb 6, 2013 · Viewed 12.2k times · Source

Some context:

I have 4 nuget packages with dependencies. They are all in pre-release mode, and they evolve from alpha to "stable" at their own pace. I want to be able to specify in the dependency definition that prereleases should be included, but when the "stable" version is available, it should update to the stable version.

In the NuGet Docs the rules for versioning are defining [ and ] to include the version number you specify and ( and ) to exlude the version number you specify.

Some examples on the impact of the versions in the nuspec file:

 <dependencies>
     <dependency id="MyComponent" version="1.2.0" />
 </dependencies>

==> This will install MyComponent 1.2.0 or higher. (not including prerelease 1.2.0-alpha)

 <dependencies>
     <dependency id="MyComponent" version="[1.2.0" />
 </dependencies>

==> This will install MyComponent 1.2.0 or higher. (not including prerelease 1.2.0-alpha)

 <dependencies>
     <dependency id="MyComponent" version="[1.2.0,2)" />
 </dependencies>

==> This will install MyComponent 1.2.0 until but not including version 2.0.0. (not including prerelease 1.2.0-alpha but includes prerelease 2.0.0-alpha)

Currently I set:

 <dependencies>
     <dependency id="MyComponent" version="(1.1.32767" />
 </dependencies>

But I find this a very ugly way and it does not really reflect the reality. (What if version 1.1.32767.1 exists?)

I would like to know how to specify that you wish to include prerelease versions in the minimum version?

Answer

Xavier Decoster picture Xavier Decoster · Feb 6, 2013

There's one important thing to note:

Depending on a pre-release makes the produced package itself also a prerelease.

It makes sense that by default pre-releases are ignored when defining the version range of dependencies because it would alter the version of the package being produced (without knowing which version to pick).

Ideally, the algorithm that checks for the version range of dependencies during installation performs a check whether the consumed package is a pre-release or not, and then either includes or excludes pre-release dependencies within the allowed version range.

I'm not sure whether this is currently the case, but looking at your question I don't think it is. You might want to log a feature request (or submit a pull request?) on http://nuget.codeplex.com