Maximum Maximum NuGet Limit Package

Is it possible to tell NuGet that you want to use the latest version of a package with a specific major version and never higher than this major version?

For example, let's take an example with jQuery: we cannot use version 2.x if we need support for older browsers. We are limited in using the latest version 1.x.

We know that the jQuery version currently available (and offered by default in the Manage Nuget Packages dialog box) is 2.1.1. Instead of using this version, we need to use the latest most recent version of the jQuery 1.x branch, currently 1.11.1.

I know how to install version 1.11.1 initially. One simple solution is to manually edit the packages.config file to replace the value of the version attribute with 1.11.1 :

 <packages> <package id="jQuery" version="1.11.1" targetFramework="net451" /> </packages> 

and build a project.

I don’t know how to tell NuGet to track the release of new versions of the 1.x branch, in order to offer me an update for them in the same way as it would when creating a new version 2.x

How NuGet Add-In notifies of a new version of a package

By default, NuGet will always try to upgrade to the latest version 2.x, not the latest version 1.x.

In other words, when using packages with older major versions, you need to manually check for releases and install NuGet every time.

I tried using an asterisk in the version attribute:

 <packages> <package id="Package1" version="1.*" targetFramework="net40" /> </packages> 

But NuGet throws an exception:

 NuGet Package restore failed for project Project1: System.IO.InvalidDataException: Unable to parse version value '1.*' from 'packages.config'. at NuGet.PackageReferenceFile.<GetPackageReferences>d__0.MoveNext() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at NuGet.VsEvents.PackageRestorer.RestorePackages(String packageReferenceFileFullPath, IFileSystem fileSystem) at NuGet.VsEvents.PackageRestorer.PackageRestore(ProjectPackageReferenceFile projectPackageReferenceFile). 

So how do you achieve the above goal?

+7
jquery visual-studio package nuget
source share
1 answer

I have found a solution. You must use the NuGet restriction.

Continuing with the jQuery example, if you need to upgrade jQuery to the latest version of branch 1.x, but not to 2.x, add the following restriction to package.config:

 <packages> <package id="jQuery" version="1.11.0" allowedVersions="[1,2)" targetFramework="net451" /> </packages> 

This allows you to be notified of new releases of the 1.x branch and never offer you an update to version 2.x that is not local to you:

enter image description here

+13
source share

All Articles