Reputation: 1174
I've been fighting with this error for several hours and can't come up with a solution that works.
I have an ASP.Net API within a multi-project solution which has its references/dependencies improperly configured and I've been trying to fix it for two days.
The issue is (I believe) that the API is missing System.Web.Http / System.Web.Http.WebHost which apparently is included with Microsoft.AspNet.WebApi.Core (per multiple other Stack Overflow questions). When trying to install it via Nuget I get the following error when attempting to resolve the dependency. Further I've gotten this error every time (see my troubleshooting later in this question):
I've done the following steps in no particular order (multiple times each in various combinations):
At this point I'm fine with a non-clean fix, as long as it fixes it. The API was working at one point, but then I checked it into TFS, created a branch, and am now working on the branch. Possibly some dependencies weren't included (?) but even if this was the case it seems like the steps I've taken should resolve the issue.
Upvotes: 31
Views: 30677
Reputation: 2908
I discovered that the packages I installed were wrong / deprecated. When I went to remove them I got this error. None of the solutions worked for me here. I went into the project file and removed the packages in question and refreshed nuget and they were gone. I was then able to download the replacement nuget package.
Upvotes: 0
Reputation: 2401
None of the other answers worked for me. It kept going in an endless loop of install, revert, restart VS, never making any progress.
What I ended up having to do was:
For crying out loud! Microsoft needs to take a lesson from yarn on how to do package management properly.
Upvotes: 3
Reputation: 176
Clearing the cache solved the problem for me. There's an option to clear the cache on Tools > Options > NuGet Package Manager > General menu, called Clear All NuGet Cache(s).
Upvotes: 8
Reputation: 191
First, uninstall via package manager console the specific NuGet package
Then, please unload the project where this nugget package was referenced for by right click -> Unload Project.
After unloading right click in the project and select "Edit {Project Name}.csproj"
Find the NuGet package entry within the XML where you previously uninstalled and delete it.
Install again the package from package manager console...
Upvotes: 4
Reputation: 149
Close the solution then go to the packages folder on your hard drive and delete all its contents. Open your application again in Visual Studio and it will automatically try to restore the packages. Clean the Solution and Build it.
Upvotes: 12