How do I update MVC 3 Project to jQuery 1.6?
Using ASP.MVC 3 + Nuget, I've added packages, but this is the first time I've tried to update a package with dependencies. So far, I'm stuck...
Created a brand new ASP.MVC 3 application. Wanted to upgrade jQuery to version 1.6 from the default jQuery 1.5.1.
In the the Package Manager Console:
PM> install-package jquery
Successfully installed 'jQuery 1.6'.
Install failed. Rolling back...
Install-P开发者_如何学编程ackage : Conflict occurred. 'jQuery 1.5.1' referenced but requested 'jQuery 1.6'. 'jQuery.vsdoc 1.5.1, jQuery.Validation 1.8.0, jQuery.UI.Combined 1.8.11' depend on 'jQuery 1.5.1'.
Is there a different syntax to update a package? Do I need to remove all those dependent packages and re-add them?
Before updating jQuery to version 1.6, you'll need to upgrade those packages to a version that supports jQuery 1.6.
Oh why so complicated? Simply open the ~/Views/Shared/_Layout.cshtml
file and replace:
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
with:
<script src="@Url.Content("~/Scripts/jquery-1.6.min.js")" type="text/javascript"></script>
after downloading jquery 1.6 and including it in your Scripts
folder obviously.
Of course if you are using a CDN (which is what you should by the way if your site is publicly facing) then simply open ~/Views/Shared/_Layout.cshtml
and replace:
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
with:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
and that's pretty much all you're gonna need.
NuGet package manager is the proper way to have JQuery upgraded from there, but, so far I didn't see it happen to us. I am using the simple copy and paste way then fix the issue when its popup.
- in [Add Library Package Reference] and [Installed packages] to remove depend packages.
- you can install jQuery.
I had the same problem when trying to install a package that required a more recent version of jQuery. I just removed all the packages that were dependent on jQuery and then re installed them one by one. It then allowed me to install my package.
精彩评论