15

Now that Visual Studio => 2010 has jQuery support, I'm wondering how I can update the project template when a new jQuery release comes out? Currently when you create a project, it automatically creates the 1.4.1 files (in VS2010), but jQuery is ever evolving, and often updates it version.

How can I tell Visual Studio to use the more recent version of jQuery (or other libraries for that matter)?

Chase Florell
  • 46,378
  • 57
  • 186
  • 376

4 Answers4

22

You can use NuGet

  1. right-click on your project in Solution Explorer
  2. click on "Manage NuGet Packages" in context menu
  3. type "jQuery" in the search box on the top right corner of the dialog box
  4. press Enter key and wait for results
  5. look for "jQuery" in the results, SELECT it and click "Install" button
  6. (after installation, you previous jquery and related files will be replaced with the latest ones)

Alternatively, you can create an Empty project and install the the nuget package(s) through the Package Manager Console. This can include ALL of the libraries that you default to.

PM> Install-Package jQuery

From there, save it as a new template, and whenever you create a new project, simply run the following terminal command before starting work.

PM> Update-Package

more info on Update-Package

Chase Florell
  • 46,378
  • 57
  • 186
  • 376
jflaga
  • 4,610
  • 2
  • 24
  • 20
  • 2
    or simply `PM> Install-Package jQuery` (because using the GUI is lame). – Chase Florell May 17 '12 at 16:30
  • 1
    One of the nice things about using the Microsoft stack is I DON'T have to use the command line to do the most mundane things. If you like typing on the command line, that's fine; go back to Apache and PERL and .php, otherwise, NO using the GUI is not lame, it is convenient and intuitive. Thanks @Jboy Floro – iGanja Mar 10 '13 at 19:17
  • 1
    This worked perfectly - except that it installed 2.0.0 when I was really wanting to go to 1.9.2 (I guess I was expecting a prompt as to which version I wanted or something); it also worked for jQueryUI, although I had to use the GUI for that, as "Install-Package jQuery-ui" failed/was unrecognized. – B. Clay Shannon-B. Crow Raven Apr 23 '13 at 15:47
  • 1
    jQuery UI from the cmd `PM> Install-Package jQuery.UI.Core` – Chase Florell Apr 23 '13 at 23:03
  • 2
    jQuery 1.9.1 from the cmd `PM> Install-Package jQuery -Version 1.9.1` – Chase Florell Apr 23 '13 at 23:04
  • jQuery UI Combined from the cmd `PM> Install-Package jQuery.UI.Combined` – Chase Florell Apr 23 '13 at 23:05
  • @iGanja You can bang on terminal commands much faster than using a GUI. Just because one builds on the .NET stack doesn't mean that they should inherently use a GUI for everything. I use powershell for [Git](https://github.com/dahlbyk/posh-git), [Nuget](http://nuget.org/), and even app installation through [Chocolatey](http://chocolatey.org/). I even have [Nano](http://sourceforge.net/projects/nano/) for windows. – Chase Florell Apr 23 '13 at 23:08
  • @ClayShannon you can find the proper `PM> ` Installs on the [Nuget](http://nuget.org) website. Once you get the hang of it, you'll find it much faster than the GUI. – Chase Florell Apr 23 '13 at 23:09
  • FWIW, I've still +1'd this answer, and changed it as accepted since running nuget through the `PM> ` console is much faster than updating templates on every release. – Chase Florell Apr 23 '13 at 23:11
  • @ChaseFlorell "Keyboard? How quaint." http://www.imdb.com/title/tt0092007/quotes?item=qt0444210 – iGanja Apr 24 '13 at 00:13
4

You can create a new project template with jQuery 1.4.2 included: http://msdn.microsoft.com/en-us/library/ms247120%28v=VS.100%29.aspx

Dave Swersky
  • 34,502
  • 9
  • 78
  • 118
  • Is there simply no way to update the existing templates? It will get old very quick if we have to create new templates every time the jQuery library gets updated. – Chase Florell May 26 '10 at 19:26
  • this like seems to show how to manually update templates: http://msdn.microsoft.com/en-us/library/ms185319%28VS.80%29.aspx – Chase Florell May 26 '10 at 19:29
  • 2
    You could modify the existing templates, I believe they are stored under the install folder for VS2010. Creating new templates is easy, however- just create a new project, replace the jQuery 1.4.1 files with 1.4.2 files, and select File-Export Template. This would allow you to keep your default templates, just in case. – Dave Swersky May 26 '10 at 19:29
2

Automatic update have some issues. If you are using jQuery library with some additional plugin and they depend on the previous jQuery library framework then they will not work. That is why you need to think carefully before updating the jQuery library from version to version.

UPDATE:

You could modify an existing template for Visual Studio which will allow you to refer to the new version of jQuery. Here is an article about creating custom Visual Studio templates.

http://msdn.microsoft.com/en-us/library/ms247119(v=VS.80).aspx

azamsharp
  • 19,710
  • 36
  • 144
  • 222
  • yes, i agree. I only want the latest release when I create a NEW project, because when I build a new project, I plan on using the latest release of jQuery (including the plugins) – Chase Florell May 26 '10 at 19:18
0

This whole Nuget/update version model in JQuery is a huge mess! (Who designed this system?)

What I do is simply avoid the JQuery template piece in Visual Studio and place the current JQuery javascript links in ONE PLACE in your web project so its pasted into every single page......either the MVC Layout page, usercontrol, or masterpage. You can mix and match controls. But it doesnt matter as modern browsers cache these files after the first download anyway.

Now when you do a JQuery update, you can fix it in one simple place in your web project. All ECMAscripts have been done this way anyway the past 15 years using server side includes or other strategies. I'm still not sure why you want a template to stuff links in hundreds of view pages in MVC you now have to customize one by one when you get different versioned files names. I think ASP.NET MVC has gone backwards in its design for that reason.

Stokely
  • 12,444
  • 2
  • 35
  • 23