Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to Install Any Package in Visual Studio 2015

People also ask

How do I install missing packages in Visual Studio?

Restore packages manually using Visual StudioEnable package restore by choosing Tools > Options > NuGet Package Manager. Under Package Restore options, select Allow NuGet to download missing packages. In Solution Explorer, right click the solution and select Restore NuGet Packages.

Why is Visual Studio not installing?

Deleting the Visual Studio Installer files and then rerunning the bootstrapper solves some update failures. Performing the following actions reinstalls the Visual Studio Installer files and resets the installation metadata. Close the Visual Studio Installer. Delete the Visual Studio Installer installation directory.


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>

I found a solution for this in my case, try to update the NuGet Package Manager.

To do this:

  1. From VS, go to Tools -> Extensions and Updates
  2. Open the Updates menu option at the left, then select Visual Studio Gallery.
  3. If there is an update for Nuget Package Installer, it should show in the list to the right. Click Update
  4. Restart Visual Studio

This let me install packages without problem again.

Hope this helps!


In my case updating Microsoft.CodeDom.Providers.DotNetCompilerPlatform and Microsoft.Net.Compilers caused the problem.

Deleting bin, obj, and packages folders and restarting Visual Studio 2015 solved the problem for me.


In general closing and re-open VS 2015 fixed most problems I have ran across. Once I did need to run a repair on one of my computers.

However I was about to do this Closing and re-opening VS2015 resolved the issue for me I figured that I would instead right click on the project and Unload Project then right click and Reload project THEN Manage Nuget worked!


You need to Clear All NuGet Caches; for this you need go to Options and click on it like this:

enter image description here


Just to help out anyone who has landed on this page after updating VS2015 to update 2 and trying to manage packages on a website, receiving the "NuGet configuration file is invalid" error, this is a known and acknowledged issue:

https://connect.microsoft.com/VisualStudio/feedback/details/2698136/nuget-configuration-is-invalid-manage-nuget-packages-for-solution-disabled

I got mine working again by installing package manager 3.4.4 (beta) from http://dist.nuget.org/index.html

They do also state update 3 for Visual Studio will also contain a fix