Tuesday, May 20, 2014

NuGet: prevent developers from upgrading to a newer version

I’m working on an Angular.js Single Page Application right now. One of the requirements is that we still have to support IE8. Therefore it’s important that we stay on the 1.* version number for jQuery because the 2.* release dropped support for IE8.

We are using NuGet and the jQuery Nuget package to keep our dependencies under control. The problem is that when we open up NuGet, jQuery was in the list of packages to update. As developers we all want to work with the latest and greatest, so I had to make sure that no one in my team accidently updated jQuery to 2.*.

You can fix this by executing following steps:

  • Open the packages.config file inside your project
  • Add an allowed versions attribute to the jQuery package
    • <package id="jQuery" version="1.9.1" allowedVersions="[1.9.1,2)" />
  • This tells NuGet that we allow all versions starting from 1.9.1 until 2(version 2 NOT included).

That’s it!

No comments: