Question

We are faced with an issue in our build environment where we would like for our continuous integration builds to download the 'latest and greatest' NuGet packages that are marked as pre-release by appropriately appending the version number with -dev.

Whenever we run the command nuget restore, it fails to pick up any pre-release versions. I have looked over the documentation on the NuGet Versioning page but it rather inconveniently omits details on how to add prerelease ranges to the allowed versions it should download in the packages.config file.

Currently, the packages.config file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Foo" version="1.0.0" targetFramework="net35" />
</packages>

And we wish to be able for NuGet to at least be able to see and then to choose the latest version from a list like the following:

  • Foo.1.0.0-dev1401291727ef87505.nupkg
  • Foo.1.0.0-dev14012918064fdf488.nupkg

Unfortunately, no pre-release versions are seen, and only 'released' packages are used by the restore process. A typical error message when trying to download a pre-release only package would be:

Unable to find version '1.0.0' of package 'Foo'.

Is there some way that I can specify a range of versions that includes pre-release packages in the packages.config file? Or even from within the .nuspec file itself?

Many thanks in advance.

Was it helpful?

Solution

There is no way AFAIK to specify to use pre-release packages within packages.config. Instead, use the -InstallPrerelease flag (PowerShell) or Prerelease flag (command-line nuget.exe) to specify that pre-release/beta packages should be installed in preference to stable packages.

Note that Foo.1.0.0-dev1234 is considered earlier than Foo.1.0.0, so if the the stable package exists (Foo.1.0.0) then any Foo.1.0.0-xxxx beta/pre-release packages will not be installed. In such a case, you'd need to up-rev the beta version to (say) Foo.1.0.1-devxxxx for it to be found as 'newer' than Foo.1.0.0.

See here for further details: How to publish nuget prerelease version package

OTHER TIPS

To indicate a prerelease version, be sure to notate it in the packages.config version:

<package id="Foo" version="1.0.0-dev1401291727ef87505" />

Version ranges are specified by using the allowedVersions attribute.

To check for updates to prerelease packages (not just stable), in the "Manage NuGet Packages" dialog, select "Include Prerelease" in the dropdown marked "Stable Only".

nuget.exe restore will download the exact version as specified in packages.config file. You will have to use update-package to update the installed packages to the latest version.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top