Nov 012013
 

A lot of people involved in web development (including myself) have hit a problem with the latest versions of jQuery. Right now there are two versions of jQuery available on NuGet – 1.9.1 and 2.0.x. According to the jQuery team, both versions will be developed in the future and for developers targeting web applications the recommended version is 1.9.1 instead of 2.0 (jQuery UI for example does not work with v2.0).

By default NuGet will install the latest version of jQuery automatically. Of course, if you use the Package Manager Console, you can force version 1.9.1. But as soon as you update and you forget to do a safe update (see my previous post here on how to do that), you are stuck with version 2.0.

To prevent such issues, an easy solution is to force the package to stay under version 2.0 by changing it in the packages.config file like this:

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

The right parenthesis means that the allowed versions should go up to (but not including) version 2.0

In the nasty situation when you’ve already updated the version and you have also dependencies on jQuery, you can downgrade the version using the following Package Manager Console commands:

Uninstall-Package jQuery –Force Install-Package jQuery -Version 1.9.1

Remember to change the packages.config afterwards.

Sep 242013
 

This is a follow-up on my previous post with a slight variation of the command. If your package source contains pre-release packages, then the previous command is not enough. The change is minor, though:

Get-Package –Updates -IncludePrerelease | ForEach-Object { Update-Package $_.Id –Safe -IncludePrerelease }

This will include all prerelase packages in the update.

Apr 152013
 

there are situations when you need to update the referenced NuGet packages and use a safe update.Safe update means that the packages are updated to the latest version that has the same major version as the current one. For example: suppose the project has a reference to “MyPackage” version 1.2.3.4. In the NuGet repository there is a MyPackage version 1.2.7.8 and one with version 2.0.0.0.

A safe update would update the package to the version 1.2.7.8, while a regular update would update it to the latest version (2.0.0.0). While the safe update can be done using the package manager UI from Visual Studio, the safe update requires using the powershell console directly.

Fortunately, there is a very easy way of updating safely all references. Open the Package Manager Console (Tools->Library Packager->Package Manager Console) and type the following command:

Get-Package –Updates | ForEach-Object { Update-Package $_.Id –Safe }