“Unable to satisfy package dependency constraints”

2020-04-07 18:34发布

问题:

I am trying to add the Breeze.Server.WebAPI2 Nuget package to Visual Studio Community 2015 RC. When I click on install I get "Unable to satisfy package dependency constraints"

The listed dependencies are:

Microsoft.AspNet.WebApi.OData (>= 5.2.2 && < 6.0.0)
Microsoft.AspNet.WebApi.WebHost (>= 5.2.2 && < 6.0.0)
Breeze.Server.ContextProvider (=1.5.4)
WebActivator

I tried adding the missing dependencies using their own packages, and now my packages.config looks like this:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Breeze.Server.ContextProvider" version="1.5.4" targetFramework="net452" userInstalled="true" />
  <package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net452" userInstalled="true" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" userInstalled="true" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" userInstalled="true" />
  <package id="Microsoft.AspNet.WebApi.OData" version="5.5.1" targetFramework="net452" userInstalled="true" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net452" userInstalled="true" />
  <package id="Microsoft.Data.Edm" version="5.6.0" targetFramework="net452" userInstalled="true" />
  <package id="Microsoft.Data.OData" version="5.6.0" targetFramework="net452" userInstalled="true" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net452" userInstalled="true" />
  <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net452" userInstalled="true" />
  <package id="System.Spatial" version="5.6.0" targetFramework="net452" userInstalled="true" />
  <package id="WebActivatorEx" version="2.0.6" targetFramework="net452" userInstalled="true" />
</packages>

But I still get the same error

EDIT To get around the problem I downloaded Visual Studio 2013 Express and used it to create the project and add the package. Then I added the project to Visual Studio 2015. Untidy, but I'm up and running.

回答1:

Two points to this response:

Firstly, according to the NuGet Package Manager GitHub issue tracker, the message you have received is a known issue, in that the identity of the problematic package should have been included in the error message, rather than the generic 'Unable to satisfy package dependency constraints'.

https://github.com/NuGet/Home/issues/241

As indicated in the Issue tracker, this has been resolved, but the version of the NuGet Client that includes the fix has not yet been released.

I have observed the same behaviour for other packages with Visual Studio 2015 RC, for which the latest NuGet Package Manager client (as of writing) is 3.0.60410.213.

While debugging this error on other packages, it led me to a potential resolution:

Secondly By default the NuGet Package Manager in Visual Studio 2015 RC is set to install packages with the Dependency Resolution behaviour set to 'lowest'. In one or two cases where I have encountered the "Unable to satisfy package dependency constraints" error, adding a package with Dependency Resolution behaviour set to 'highest' has resolved this issue, presumably due to either incorrect dependencies specified in the parent NuSpec manifest, or incompatibilities as specified in the dependency graphs manifests.

One example of the latter a higher version of a package is installed in Visual Studio 2015 RC project templates than is supported by a third-party package in the dependency chain. The NuGet bug fix mentioned above should make identifying these situations much easier.



回答2:

I had the same problem, I had Nuget version 3.0.60410.213. I was trying to install EasyNetQ but I kept getting that error also. I tried using "highest" in Dependency Resolver, but no cigar.

My solution was to install the dependency individually. I installed the RabbitMQ.Client package, then EasyNetQ would install.