Resolved Can't install nuget packages. Button grayed out.

Frika

New member
Joined
Apr 25, 2023
Messages
3
Programming Experience
Beginner
I can't install nuget packages because the button is grayed out. Any idea what might be the reasons for that? I had no success finding the solution online and the videos with guides for visual studio 2019 or 2023 online show clearly that once the studio is installed and when you create a new project there should be no issues with installing packages. Any advices are more than welcome. Thank you in advance.
 
Solution
I can't help but point out at the fact of how much pure HATE I have toward these type of problems...
@jmcilhinney thank you for the help. Thanks to the pointer you gave me I managed to get to the bottom of the issue... I am going to leave the solution to my problem here with the hopes that it might help someone in the future.
Following @jmcilhinney's remark about adding/creating a new solution to the project I tried to do so. The result was the following error in a pop up screen -> The SDK 'Microsoft.NET.Sdk' specified could not be found. E:\ConsoleApp3\consoleapp3.csproj
So I thought it might have been an issue if me using .net version which doesn't have sdk installed properly. I have 0 idea what SDK is and...
Please provide a FULL and CLEAR explanation of the problem. EXACTLY what type of project did you create? EXACTLY how are you trying to add a NuGet package? What button are you talking about - I usually use a menu item? This is a situation where a screenshot would be useful.
 
Please provide a FULL and CLEAR explanation of the problem. EXACTLY what type of project did you create? EXACTLY how are you trying to add a NuGet package? What button are you talking about - I usually use a menu item? This is a situation where a screenshot would be useful.

Thank you for taking the time to help with my issue.
I try to create 2 types of projects: Console App and NUnit Test Project.
I already stated what my problem is above but if i have to go one extra step I would also mention that I can't install packages through Tools -> NuGet Package Manager -> Package Manager Console.
The error i get when I am trying to install packages through PK is:
NuGet\Install-Package : Project 'Default' is not found.
At line:1 char:1
+ NuGet\Install-Package Newtonsoft.Json -Version 13.0.3
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Default:String) [Install-Package], ItemNotFoundException
+ FullyQualifiedErrorId : NuGetProjectNotFound,NuGet.PackageMan


I am sharing screenshots so you can get the general idea of what the gray out buttons look like. In the screenshots I am using a new project for Console App but the behavior for NUnit Test Project is the same.

Let me know if I can provide additional information.
 

Attachments

  • 1.png
    1.png
    68.8 KB · Views: 201
  • 2.png
    2.png
    87.1 KB · Views: 197
  • 3.png
    3.png
    88.6 KB · Views: 196
Your issue has nothing to do with NuGet. You add NuGet packages to a project and, according to your Solution Explorer, you have no projects in your solution, so there's nothing to add a NuGet package to. This is the second time I've seen this in recent days, so it may be a new bug in VS.

It looks like you have created a new project and VS has created both the solution and the project but it hasn't actually added the project to the solution. The fact that you have a code file open means that the project must have been created. I'm not sure whether there's a way to prevent this bug manifesting so we may just have to wait until Microsoft patch VS.

As a workaround, I would suggest that you right-click the solution and select the option to add an existing project, then select the project file that you have just created. That should add the project to the solution as it should have been in the first place, then you can do all the things related to projects, like adding NuGet packages.
 
For the record, I just tried creating a new Console Application project in VS 17.5.4 and it worked for me. If you're using an older version, maybe you should update and see whether that fixes the issue. If you are seeing this issue on the latest version, it mustn't be affecting everyone or every project.
 
I can't help but point out at the fact of how much pure HATE I have toward these type of problems...
@jmcilhinney thank you for the help. Thanks to the pointer you gave me I managed to get to the bottom of the issue... I am going to leave the solution to my problem here with the hopes that it might help someone in the future.
Following @jmcilhinney's remark about adding/creating a new solution to the project I tried to do so. The result was the following error in a pop up screen -> The SDK 'Microsoft.NET.Sdk' specified could not be found. E:\ConsoleApp3\consoleapp3.csproj
So I thought it might have been an issue if me using .net version which doesn't have sdk installed properly. I have 0 idea what SDK is and what it does again totally new to all of this stuff.
I went to Visual Studio Installer -> Clicked on "MODIFY" for the version that I was trying to use. -> Selected everything with SDK in there (I am not sure if this helped resolving my issue)

Next -> Open a command prompt and issue the following command -> dotnet --list-sdks -> this will display a list of the sdks you have installed on your pc. If you get blank (which is what i've got) than chances are you have the problem I have.
Just to be on a safe side I am leaving a link over here from where you can download the latest SDKS from microsoft -> Download .NET (Linux, macOS, and Windows)

Follow the next steps:
  1. Open the Control Panel by searching for it in the Start menu or using the Windows key + X shortcut.
  2. Click on "System and Security" and then click on "System".
  3. On the left-hand side of the window, click on "Advanced system settings".
  4. In the "System Properties" window that appears, click on the "Environment Variables" button.
  5. Follow the picture which I have uploaded below which is basically -> System variables window -> double click Path -> Over here there are 2 paths "C:\Program Files\dotnet\" and "C:\Program Files (x86)\dotnet\" now in my case I am on Windows 10 OS 64 bit so I removed the "C:\Program Files (x86)\dotnet\"
  6. Close all the windows and restart your PC.

This should resolve your issue... at least it did for me. If you open command prompt and issue the "dotnet --list-sdks" command it should give you a list of SDKS you have installed now.
 

Attachments

  • 4.png
    4.png
    127.8 KB · Views: 219
Solution
An SDK is a Software Development Kit. It is basically the libraries and possibly tools that represent a framework you want to develop software with. The SDK you need in this case would normally be installed as part of VS. It's odd that you were able to select a project template that corresponds to an SDK you don't have installed, so the issue may be in the VS installer. Maybe simply repairing VS would have fixed it, or maybe not.

Before you get too big on the hate, remember that VS is software and all software has bugs. VS is created by a large team of experienced developers but it's also incredibly complex software, so there will always be bugs. It can certainly get annoying but, until you can create software with no bugs yourself, don't expect others to do so. :)
 

Latest posts

Back
Top Bottom