6/19/12

Install-Package Conflict in JQuery Reference when using Package Manager Console

With Visual Studio 2010, we can use the Package Manager Console to install Javascript packages like Knockout and others. The saves a lot of time because all the resources and references associated to the package are downloaded and configured on the project that you are working on. In some instances, we may get an issue where a package depends on a reference to a JavaScript framework that is different to what is configured on your project. To see how we can go about to do handle such conflicts, lets try to add the SignalR package to an MVC 3 project.
  • Create an empty MVC 3 Web Project
  • Open the Package Manager Console (Tools->Library Package Manager->Package Manager Console)
  • Type this Command: install-package signalr
This console is basically a PowerShell console which allows us to execute NuGet commands. In this case the install-package command, tries to download and configure a package. Depending on your configuration, you may get this conflict error:

Install-Package : Conflict occurred. 'jQuery 1.5.1' referenced but requested 'j
Query 1.6.4'. 'jQuery.vsdoc 1.5.1, jQuery.Validation 1.8.0,

It looks like our project is set to use jQuey 1.5.1, but the package has a dependency on jQuery 1.6.4. We need to look at how our project is configured.  Look at the packages.config file in the project.



This file is a NuGet configuration file which is used to track the packages and version. This file is used when we attempt to configure a project using the NuGet commands. It looks at the file, and it checks to make sure that what you want to do does not cause any possible conflicts. In our case, we can see that the project is set to use jQuery 1.5.1. We need to update this setting to be able to import this package in our project.  We also need to make sure that the new jQuery reference is added. Remove the reference to jQuery (first two lines) from the file.

Save the file and on the Package console run the command again.  install-package signalr.  You should now see messages indicating that the file was correctly installed. If you check the file again, you will see that the file is now upgraded with the new jQuery and the signalr files.



You should also look at the Script folder, and you will see that the jquery-1.6.4 files as well as the jquery.signalR js files have been added.

You know just need to make sure to remove the old jquery (1.5) files, and you should be ready to continue.

I hope this helps.
og-bit.com



0 comments :