Unable to Install Any Package in Visual Studio 2015
I found a solution for this in my case, try to update the NuGet Package Manager.
To do this:
- From VS, go to Tools -> Extensions and Updates
- Open the Updates menu option at the left, then select Visual Studio Gallery.
- If there is an update for Nuget Package Installer, it should show in the list to the right. Click Update
- Restart Visual Studio
This let me install packages without problem again.
Hope this helps!
Closing and re-opening VS2015 resolves the issue.
It seems that in some cases, simply reloading the affected project will work.
tl;dr - Delete this:
%AppData%/Nuget/Nuget.config
Warning: If you had custom NuGet sources, this will remove them, and you'll have to re-add them.
Longer version:
You might have corrupted your NuGet config. Oh no :(
Nuget.config is a file used to keep track of all of the places that NuGet pulls from, as well as configuring other things. More likely than not, this xml file got broken somehow.
- Go to this path:
C:\Users\{{username}}\AppData\Roaming\
- Delete
Nuget.config
- Restart VS for good measure
For reference: in the good days of 2017, your file should look something like this
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<activePackageSource>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</activePackageSource>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
<!-- Others -->
</packageSources>
<packageSourceCredentials>
<!-- secret stuff -->
</packageSourceCredentials>
</configuration>