How do I fix the NuGet Package Manager not opening/working?

Viewed 1110

I have Visual Studio Professional 2019, and I'm working on debugging a project that has issues with its NuGet packages. The NuGet Package Manager button is present when right clicking the solution.

enter image description here

But when I click the button, nothing happens. Nothing opens. Absolutely nothing, no error code, no messagebox, no warning in the debugger. I've tried uninstalling and reinstalling my NuGet extensions, nothing changed. I uninstalled and reinstalled visual studio and made sure to enable the package manager, nothing. I restarted my computer and Visual Studio, nothing.

The thing is, I tried opening another project (this time one of my own), and the package manager works fine, which leads me to believe the guy who made this program disabled the package manager entirely, but somehow kept the button there? I don't know exactly what the hell he did, but right now I'm not able to actually work into getting the packages I need to even launch the program. I can't look at ANY part of it either until the packages are added, because Visual Studio won't display anything.

2 Answers

Projects and solutions can't change the Visual Studio menu options themselves. This issue might occur for you if you are missing a .sln file for your project or if it has become corrupted (you don't actually need a .sln file to open a project in Visual Studio). If you notice, Visual Studio's NuGet Package Manager option in the menu says

Manage NuGet Packages for Solution

(emphasis mine). If you don't have the .sln file and associated properties file, then Visual Studio can't do anything when you click on that menu... there is no 'Solution' (.sln file) for it to manage packages for, in essence

Check the original working repository of the code where the project was created and look for a .sln file and a .vssscc file, and copy those over to your new working repository and open the project via that .sln file, and NuGet Package Manager should open successfully now.

If you can't find them or if the working repository doesn't exist anymore, then you'll need to create a new solution in Visual Studio and import/copy all the project files into the new solution. I don't know of a way to 'rebuild' or 'recreate' a solution file and solution properties file for a project that doesn't have them anymore.

For reference, I have had this issue when running VS on a new computer and opening projects I created, so it is not necessarily some form of 'sabotage'.

Though perhaps not the case for the original question asker, one cause of the "NuGet Package Manager" just won't open issue is a syntax error in the project's packages.config file.

In my case, a merge conflict I didn't notice added merge text (the "<<<<<.." type stuff) to the config file. That lead to a silent read error, which I didn't notice until I opened the actual NuGet Package Manager Console.

Related