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:
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.
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.
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.
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.
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.
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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With