Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I keep Nuget on the jQuery 1.9.x/1.x path (instead of upgrading to 2.x)?

Tags:

jquery

nuget

Like most people, I'm using the jQuery Nuget package to keep up to date.

However, with the release of jQuery 2.0 I'm now prompted to upgrade jQuery 1.9.1 to 2.0. At this time I have enough visitors across my sites using 'ancient' versions of browsers that I'd rather stick with 1.9.x and jQuery Migrate.

Is there anyway to tell Nuget to stick with a particular version (1.9.x) when checking for updates of a package (jQuery or otherwise)?

I'm using the Visual Studio 2010/2012 extensions, but if I need to use the command line interface within VS to work around this issue, I certainly will.

Note: One thing in the back of my mind is that they messed up the update. Since jQuery 1.9.x and 2.0.x/2.x are fairly different, it seems they should have created a jQuery 2(.0.x|.x) package instead.

Of course then people who actually want to update to 2.x will have to know about it and switch which package they want installed. But given that it contains breaking changes, maybe that's better?

like image 339
James Skemp Avatar asked Apr 20 '13 22:04

James Skemp


4 Answers

In my opinion, this is a mistake on the package author's part. An update which removes support for several browsers should have been made into a separate version 2 nuget package and advertised accordingly, i.e. with significant disclaimers. The 1.9 library is not legacy and will receive further updates in the future. I've been in touch with the package author and will write more if I receive a reply.

In the interim, you can constrain the version of your package by using the following syntax in your packages.config:

<package id="jQuery" version="1.9.1" allowedVersions="[1.9.1]" />

There's more information on version constraints here:

http://docs.nuget.org/docs/reference/Versioning

After making the config change, an update should not upgrade your jQuery package to the 2.0 release. There have been issues in the past with the UI package manager not respecting the allowedVersions attribute (https://nuget.codeplex.com/workitem/1891), so you may have to use the command line if you encounter this problem.

However, none of this solves the problem of what happens when the 1.9 branch gets updated because the package feed will now be on the 2.0+ track. I assume you'll have to switch to a new nuget package specifically written to support the 'legacy' 1.x version, or copy the script in manually each time.

In any case, I'll update this when I learn more.

Edit:

The package author has stated that both the 1.x and 2.x paths will be supported in the future, i.e. the package feed will contain parallel versions instead of them being split. As far as I can see, the solution is to use a version constraint at the package config level to prevent an update to the 2.x version, e.g.:

<package id="jQuery" version="1.9.1" allowedVersions="[1.9.1,2)" />

(Specifying both min and max versions in allowedVersions should allow updating without risking a switch to the 2.x version. By the way, the right parenthesis looks strange, but is correct - it means 'less than version 2'.)

like image 128
Dave R. Avatar answered Oct 19 '22 23:10

Dave R.


how about to specify the version?

PM> Install-Package jQuery -Version 1.9.1

References: http://nuget.org/packages/jQuery/1.9.1

like image 19
TeYoU Avatar answered Oct 19 '22 22:10

TeYoU


Nuget now has a jquery1 package that only tracks the 1.x branch, so you should be able to swap out the core jQuery package for this one.

like image 8
Chris J Avatar answered Oct 19 '22 22:10

Chris J


I combined the two solutions from the top for @TeYoU

First I Installed the package from the package manager console:

Tools Menu -> Library Package Manager -> Package Manager Console

PM> Install-Package jQuery -Version 1.9.1

Then I edited the packages.config as @Dave R. says:

<package id="jQuery" version="1.9.1" allowedVersions="[1.9.1,2)" />

Then I updated to the current version, currently 1.10.2 using Nuget Manager and it worked like a charm.

like image 4
jmacboy Avatar answered Oct 19 '22 23:10

jmacboy