Somehow during the upgrade to VS2012 and .NET 4.5, I've managed to get NuGet confused. There are packages that appear in the package manager (and the packages folder) that I cannot delete (I believe they are legacy ASP.NET NuGet packages that have been replaced with new package names with the new version. They each have only a Manage button -- but no uninstall button. And when you look to see where they are used, you can see that they are referenced by none of the solution's projects? They are NOT displaying an Uninstall?
11 Answers
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
I've found a workaround for this.
- Enable package restore and automatic checking (Options / Package Manager / General)
- Delete entire contents of the packages folder (to Recycle Bin if you're nervous!)
- Manage Nuget Packages For Solution
- Click the restore button.
NuGet will restore only the packages used in your solution. You end up with a nice, streamlined set of packages.
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:
Tools-> Nuget Package Manager -> Manage Nuget Packages for Solution
In the left column where is 'Installed packages' select 'All', so you'll see a list of installed packages and Manage button across them.
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.
If you have removed package using Uninstall-Package utility and deleted the desired package from package directory under solution (and you are still getting error), just open up the *.csproj file in code editor and remove the tag manually. Like for instance, I wanted to get rid of Nuget package Xamarin.Forms.Alias and I removed these lines from *.csproj file.
And finally, don't forget to reload your project once prompted in Visual Studio (after changing project file). I tried it on Visual Studio 2015, but it should work on Visual Studio 2010 and onward too.
Hope this helps.
Solution 1
Use the powershell pipeline to get packages and remove in single statement like this
Get-Package | Uninstall-Package
Solution 2
if you want to uninstall selected packages follow these steps
- Use
GetPackages
to get the list of packages - Download Nimble text software
- Copy the output of
GetPackages
in NimbleText(For each row in the list window) - Set Column Seperator to
(
if required - Type
Uninstall-Package $0
(Substitute using pattern window) - Copy the results and paste them in Package Manage Console
That be all folks.
One NuGet package can reference another NuGet package. So, please be very careful about inter-package dependencies. I just uninstalled a Google map package and it subsequently uninstalled underlying packages like Newtonsoft, Entity Framework, etc.
So, manually deleting particular package from packages folder would be safer.
From the Package Manager console window, often whatever command you used to install a package can be used to uninstall that package. Simply replace the INSTALL command with UNINSTALL.
For example, to install PowerTCPTelnet, the command is:
Install-Package PowerTCPTelnet -Version 4.4.9
To uninstall same, the command is:
Uninstall-Package PowerTCPTelnet -Version 4.4.9
If you want to use Visual Studio option, please see How to remove Nuget Packages from Existing Visual Studio solution:
Step 1:
In Visual Studio, Go to Tools/NuGet Package Manager/Manage NuGet Packages for Solution…
Step 2:
UnCheck your project(s) from Current solution
Step 3:
Unselect project(s) and press OK