Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can 'nuget restore' download pre-release packages?

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.

like image 948
Aaron Cunnington Avatar asked Jan 30 '14 05:01

Aaron Cunnington


People also ask

How do I redownload NuGet packages?

Switch to the Browse tab, search for the package name, select it, then select Install). For all packages, delete the package folder, then run nuget install . For a single package, delete the package folder and use nuget install <id> to reinstall the same one.

What makes a NuGet package prerelease?

Pre-release versions are then denoted by appending a hyphen and a string after the patch number. Technically speaking, you can use any string after the hyphen and NuGet will treat the package as pre-release.

Where do NuGet packages get downloaded to?

The global-packages folder is where NuGet installs any downloaded package. Each package is fully expanded into a subfolder that matches the package identifier and version number. Projects using the PackageReference format always use packages directly from this folder.

What is the difference between NuGet restore and dotnet restore?

nuget restore will ensure all of your NuGet dependencies are downloaded and available to your project. Whereas dotnet restore is a complete restoration of all NuGet dependencies as well as references and project specific tools. Meaning that if you run nuget restore , you are only restoring NuGet packages.


1 Answers

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".

like image 55
DonBecker Avatar answered Sep 20 '22 16:09

DonBecker