asp.net-mvcvisual-studio-2013cors

Not able to install Microsoft.AspNet.WebApi.Cors from NuGet


I just upgrade my project from Visual Studio from 2010 to 2013 to support Cross-Origin Resource Sharing (CORS) in my WebApi. Now when I am installing Microsoft.AspNet.WebApi.Cors package from NuGet then I am getting 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

Solution

  • I had exact the same problem with another NuGet library.

    Please try this steps:

    1. Updates

    Proof if your installed NuGet version is on the newest version

    2. Clear cache

    Use the NuGet command prompt and clear the cache:

    You can list the 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 simply a folder on your computer, you can proof delete the remaining files manually under %LOCALAPPDATA%\NuGet\Cache.

    Or just run this in administrator CMD:

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