24

In one of the projects I needed to reinstall the jQuery NuGet package (a MVC solution).

There were also a "Microsoft.jQuery.Unobtrusive.Validation", that I should uninstall before removing the jQuery package.

Now I try to (re)install the jQuery package, and all dependent packages I removed before. The "Microsoft.jQuery.Unobtrusive.Validation" package breaks saying:

Attempting to resolve dependency 'jQuery (≥ 1.8)'.
Attempting to resolve dependency 'jQuery.Validation (≥ 1.8)'.
Attempting to resolve dependency 'jQuery (≥ 1.3.2 && ≤ 1.6)'.
Updating 'jQuery 1.8.0' to 'jQuery 1.4.1' failed.
Unable to find a version of 'Microsoft.jQuery.Unobtrusive.Validation' that is compatible with 'jQuery 1.4.1'.

was is das? I need to use the latest jQuery (2.0.xx)!

I should remark that the similar "Microsoft.jQuery.Unobtrusive.Ajax" package does not have this 'bug'. It was installed without problems.

PS. Now I tried to install the (non-Microsoft)jQuery.Validation...

this is the error log:

Attempting to resolve dependency 'Microsoft.jQuery.Unobtrusive.Validation (≥ 2.0.20613.0)'.
Attempting to resolve dependency 'jQuery.Validation (≥ 1.8 && < 2.0)'.
Attempting to resolve dependency 'jQuery (≥ 1.3.2 && ≤ 1.6)'.
Installing 'jQuery 1.4.1'. Successfully installed 'jQuery 1.4.1'.
Installing 'jQuery.Validation 1.8'.
Successfully installed 'jQuery.Validation 1.8'.
Installing 'Microsoft.jQuery.Unobtrusive.Validation 2.0.20710.0'.
Successfully installed 'Microsoft.jQuery.Unobtrusive.Validation 2.0.20710.0'.
Installing 'jQuery.Validation.Unobtrusive 2.0.20710.0'.
Successfully installed 'jQuery.Validation.Unobtrusive 2.0.20710.0'.
Install failed.
Rolling back...
Updating 'jQuery 1.9.0' to 'jQuery 1.4.1' failed. Unable to find versions of 'bootstrap, jQuery.BlockUI, Microsoft.jQuery.Unobtrusive.Ajax' that are compatible with 'jQuery 1.4.1'.

Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
serhio
  • 28,010
  • 62
  • 221
  • 374

3 Answers3

48

I just ran into this same issue now.

Using NuGet I added "jQuery", then "jQuery Validatation" Tried "Microsoft jQuery Unobtrusive Validation" again, this time it installed nicely :)

Dragick
  • 675
  • 1
  • 7
  • 15
  • 1
    Yep... for sure this is a bug with NuGet not being able to correctly solve dependencies. Just tweeted that to the NuGet team: https://twitter.com/johnleniel/status/453250061473161217 – Leniel Maccaferri Apr 07 '14 at 19:27
  • +1 Pretty frustrating that `Microsoft.Jquery.Unobtrusive.Validation` doesn't know to check for its own `Jquery.Validation` dependency. And what's this `jQuery 1.4.1` business, anyway?? – Brian Lacy Jul 24 '14 at 22:12
  • Is it possible to download this package separately without the use of `nuget`? – phougatv Feb 02 '16 at 06:23
10

jQuery 1.x and jQuery 2.x are two separate branches of jQuery. jQuery 1.x continues to have support for older versions of IE (6/7/8), while 2.x does not. In essence, there are two "latest" versions of jQuery.

jQuery validation is not currently tested with the 2.x branch and currently lists 1.6.4, 1.7.2, 1.8.3, 1.9.1, 1.11.1 as supported/tested. It may work fine with jQuery 2.x, but as it doesn't technically currently support it. I have been sticking with the latest jQuery 1.x version because of this.

How do you fix this?

In order to fix this issue, switch to the latest jQuery 1.x version (currently 1.11.1) by typing the following command in your Package Manager Console to update the reference from 2.x to 1.11.1.

Install-Package jQuery -Version 1.11.1

Like @Dragick said previously there is a weird dependency issue where Microsoft.jQuery.Unobtrusive.Validation nuget can't determine the jQuery version if you try to directly install it without already having jQuery.Validation nuget installed. To fix this, install them separately like the following:

Install-Package jQuery.Validation
Install-Package Microsoft.jQuery.Unobtrusive.Validation
scottheckel
  • 9,106
  • 1
  • 35
  • 47
2

Same issue here. I left the jQuery 2.1.0 package installed then installed jQuery Validate next, then installed jQuery Unobtrusive and it worked.

Chris Morgan
  • 1,074
  • 11
  • 11