Install-Package: The current environment doesn't have a solution open.


Scenario:

While trying to install a nuget package in Visual Studio you receive the following error:

   Install-Package : The current environment doesn't have a solution open.
   At line:1 char:1
   
   + Install-Package <PackageName>
   + ~~~~~~~~~~~~~~~~~~~~~~~
       + CategoryInfo          : InvalidOperation: (:) [Install-Package], InvalidOperationException
       + FullyQualifiedErrorId : NuGetNoActiveSolution,NuGet.PowerShell.Commands.InstallPackageCommand

Solution:

This typically occurs when the solution file hasn't been saved yet. A common use case would be starting Visual Studio, creating a new project and then trying to add the NuGet package before the solution has been saved the first time. To fix the issue, force save the solution, choose your destination location and then try to re-add your nuget package.

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.