Failed to install Microsoft.AspNet.WebApi.Cors from NuGet

I am just updating my project from Visual Studio from 2010 to 2013 to support Cross-Origin Resource Sharing (CORS) in my WebApi. Now when I install the Microsoft.AspNet.WebApi.Cors package from NuGet, I get the following error.

I am using Visual Studio 2013, Asp.Net MVC 5

PM> Install-Package Microsoft.AspNet.WebApi.Cors Attempting to resolve dependency 'Microsoft.AspNet.WebApi.Core (≥ 5.2.3 && < 5.3.0)'. Attempting to resolve dependency 'Microsoft.AspNet.WebApi.Client (≥ 5.2.3)'. Install-Package : An item with the same key has already been added. At line:1 char:1 + Install-Package Microsoft.AspNet.WebApi.Cors + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Install-Package], ArgumentException + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand 
+5
source share
3 answers

I had the same problem with another NuGet library.

Please follow these steps:

1. Updates

Proof that your installed version of NuGet is on the latest version

2. Clear cache

Use the NuGet command line and clear the cache:

You can specify local caches with this command:

nuget locals all -list

You can clear all caches with this command:

nuget locals all -clear

3. Check cache

The NuGet cache is just a folder on your computer, you can confirm the deletion of the remaining files manually in% LOCALAPPDATA% \ NuGet \ Cache.

Or just run this in the admin CMD:

del %LOCALAPPDATA%\NuGet\Cache\*.nupkg /q

+3
source

The message says that the package is already installed. try uninstalling before reinstalling:

Uninstall package Microsoft.AspNet.WebApi.Cors

+1
source

If this can help someone else, I tried to follow the steps of Steffen Mangold, but this does not work completely.

If you have a build error, for example:

System.Web.Http, Version=5.0.0.0

after executing this Install-Package Microsoft.AspNet.WebApi.Cors command Install-Package Microsoft.AspNet.WebApi.Cors

Try the following:

1 - Run this in admin CMD

del %LOCALAPPDATA%\NuGet\Cache\*.nupkg /q

2 - Run this in the package manager console

Install-Package Microsoft.AspNet.WebApi

This will install the missing assemblies and fix the error.

0
source

Source: https://habr.com/ru/post/1243362/


All Articles