Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with uninstalling NuGet Packages

I'm trying to uninstall some packages installed by NuGet. According to the doc described here, I should see an Uninstall button (first screenshot below) when I select the installed package. However, I only see a Manage button (second screenshot below). Can anyone please tell me how to uninstall the packages?

NuGet Doc Screenshot

My Screenshot

like image 671
StarCub Avatar asked Jul 06 '11 21:07

StarCub


3 Answers

If you scroll down to the Managing Installed Packages section of the NuGet documentation page you linked to you will see the Manage button and an explanation.

In NuGet 1.4 a new feature was introduced allowing you to select the solution in the Solution Explorer and add/remove packages from multiple projects in one step. Previously you had to select each project in the Solution Explorer and add/remove the package from each project one at a time.

If you click the Manage button a Select Projects dialog will be displayed where you can uncheck the projects that you want the NuGet package to be uninstalled from.

enter image description here

If you select the project instead of the solution in the Solution Explorer you can add/remove packages from that selected project. In this case you will only see the Install and Uninstall buttons.

like image 73
Matt Ward Avatar answered Jan 05 '23 05:01

Matt Ward


Finally, I found I had to manually edit the .sln solution file and remove these lines:

GlobalSection(ExtensibilityGlobals) = postSolution
        EnterpriseLibraryConfigurationToolBinariesPath = packages\Unity.2.1.505.0\lib\NET35;packages\Unity.Interception.2.1.505.0\lib\NET35;packages\EnterpriseLibrary.Common.5.0.505.0\lib\NET35;packages\EnterpriseLibrary.Data.5.0.505.0\lib\NET35
EndGlobalSection

After removing the above lines in the solution file, those packages disappeared in the NuGet Packages Window "Installed package" page. There is only one package left and I can now see the "Uninstall" button.

enter image description here

EDIT: I also had to delete the packages folder in my solution directory.

like image 27
StarCub Avatar answered Jan 05 '23 07:01

StarCub


Sometimes there are dependencies that disallow uninstalling a package, but you need to do so anyway (i.e. if you inadvertently install two different versions of a package with dependencies).

When this happens, the only way to uninstall the packages is to force the uninstallation, and this can only be done through the Package Manager Console.

Before going to the Console, you should open the Manage NuGet Packages window, and note down the Id and Version of your package, which appears on the right pane when you click on the package.

Then you can close the Manage window, and open the console (Package Manager Console), and run this command:

uninstall-package -Id YourPackageId -Force -Version YourPackageVersion

Note the -Force parameter. For example

uninstall-package -Id Unity -Force -Version 3.0.1304.0

This command allows to uninstall the version 3 when it is installed in parallel with version 2, which can't be done throgh the Manage window.

like image 27
JotaBe Avatar answered Jan 05 '23 05:01

JotaBe