Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I delete NuGet packages that are not referenced by any project in my solution?

People also ask

How do I completely remove a NuGet package?

In the solution, right click on References and Manage NuGet packages, find the "Installed" tab in the upper right. Hover over the package and the "X" will appear to uninstall.

Can I delete C :\ Users NuGet packages?

Yes, the . nuget folder is used as a cache for packages downloaded to speed up project restore and compilation. It can safely be removed.

Where are NuGet packages stored in a solution?

config and PackageReference. And for PackageReference format, the packages are stored in C:\Users\xxx\. nuget\packages .


I've found a workaround for this.

  1. Enable package restore and automatic checking (Options / Package Manager / General)
  2. Delete entire contents of the packages folder (to Recycle Bin if you're nervous!)
  3. Manage Nuget Packages For Solution
  4. Click the restore button.

NuGet will restore only the packages used in your solution. You end up with a nice, streamlined set of packages.


You can use Package Manager Console with command: Uninstall-Package PackageId to remove it, or just delete package folder from 'packages' folder under solution folder. More information about Package Manager Console you can find here: http://docs.nuget.org/docs/reference/package-manager-console-powershell-reference


First open the Package Manager Console. Then select your project from the dropdown list. And run the following commands for uninstalling nuget packages.

Get-Package

for getting all the package you have installed.

and then

Uninstall-Package PagedList.Mvc

--- to uninstall a package named PagedList.MVC

Message

PM> Uninstall-Package PagedList.Mvc
Successfully removed 'PagedList.Mvc 4.5.0.0' from MCEMRBPP.PIR.

If you want to delete/uninstall Nuget package which is applied to multiple projects in your solutions then go to:

  1. Tools-> Nuget Package Manager -> Manage Nuget Packages for Solution

  2. In the left column where is 'Installed packages' select 'All', so you'll see a list of installed packages and Manage button across them.

  3. Select Manage button and you'll get a pop out, deselect the checkbox across project name and Ok it

The rest of the work Package Manager will do it for you.