Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I uninstall *all* nuget packages from a solution in Visual Studio

I know I can uninstall-package from the PM console. I got into some dependency issues with another project and I want to start over, and I need to delete all packages in one shot. Is there a way?

like image 645
dgorti Avatar asked Feb 19 '15 00:02

dgorti


People also ask

How do I delete all NuGet packages?

Starting in Visual Studio 2017, use the Tools > NuGet Package Manager > Package Manager Settings menu command, then select Clear All NuGet Cache(s).

Can I delete NuGet packages?

In exceptional situations such as copyright infringement and potentially harmful content, packages can be deleted manually by the NuGet team.

Where is manage NuGet packages for solution?

Tools > Extension Manager > Online Gallery; You will see "Manage NuGet Packages For Solution" and press download. After finishing download, Save your project first, and restart your Visual Studio, that's all.


1 Answers

To get all packages from all projects in the solution use Get-Package. To get all packages from a specific project use Get-Package -ProjectName "YourProjectName".


Remove all packages from all projects in the solution

Be careful: This will uninstall ALL packages in the solution. If -Force parameter is used, packages are removed even if dependencies exist.

Get-Package | Uninstall-Package -RemoveDependencies -Force 


Remove all packages from a specific project within a solution

Be careful: This will uninstall ALL packages in the project. If -Force parameter is used, packages are removed even if dependencies exist.

Get-Package -ProjectName "YourProjectName" |  Uninstall-Package -ProjectName "YourProjectName" -RemoveDependencies -Force 
like image 65
Norman Avatar answered Sep 26 '22 00:09

Norman