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

dgorti picture dgorti · Feb 19, 2015 · Viewed 44.8k times · Source

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?

Answer

Norman picture Norman · May 25, 2016

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