像大多数人一样,我用jQuery Nuget package来保持最新.

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?

推荐答案

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]" />

这里有关于版本约束的更多信息:

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

更改配置后,更新不应将jQuery包升级到2.0版本.过go ,UI包管理器存在不遵守allowedVersions属性(https://nuget.codeplex.com/workitem/1891)的问题,因此如果遇到此问题,可能必须使用命令行.

然而,这些都不能解决1.9分支更新时会发生什么的问题,因为包提要现在将位于2.0+轨道上.我想您必须切换到一个新的nuget包,该包是专门为支持"legacy"1而编写的.或每次手动复制脚本.

无论如何,当我了解到更多信息时,我会更新此信息.

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'.)

Jquery相关问答推荐

通过 jQuery 提取 application/json 数据

jQuery .first() 方法返回第一个元素的集合

DataTables - this.api 用于回调函数中的多个表

修改对象数组中的对象属性

在jQuery中获取所有选定复选框值的最佳方法

如何通过 Select 插件使用 jQuery 验证?

使用跨域帖子发送凭据?

Zepto 和 jQuery 2 有什么区别?

在 jQuery 中处理多个 ID

blueimp 文件上传插件中的 maxFileSize 和 acceptFileTypes 不起作用.为什么?

所有选中复选框的 jQuery 数组(按类)

C# String.IsNullOrEmpty Javascript 等效项

Jquery:如何判断元素是否具有某些 css 类/样式

JavaScript 等效于 jQuery 的扩展方法

通过 AJAX MVC 下载 Excel 文件

javascript,是否有像 isArray 这样的 isObject 函数?

请求的资源错误中不存在Access-Control-Allow-Origin标头

fancybox2 / fancybox 导致页面跳转到顶部

使用 TypeScript 设置 window.location

如何使用 jQuery 的 form.serialize 但排除空字段