开发者

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?

Problem with uninstalling NuGet Packages

Problem with uninstalling NuGet Packages


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.

Problem with uninstalling NuGet Packages

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.


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.

Problem with uninstalling NuGet Packages

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


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.


I had similar issues recently. My project worked fine but I couldn't add or remove any packages via the NuGet package Manager anymore because EnterpriseLibrary 5.0.505 was shown as missing from the source. But trying to either restore or delete it failed with an error "unable to find version '5.0.505. of package 'EnterpriseLibrary'".

I traced this down to having the following reference in the packages.config file:

<package id="EnterpriseLibrary" version="5.0.505" targetFramework="net4" />

Comparing this with other solutions to which I added the package more recently I changed it to, the following, which fixed the issue:

<package id="EnterpriseLibrary.Common" version="5.0.505.0" targetFramework="net4" />

I never edited any package.config files manually, so I don't know how the mismatch happened. Maybe the reference changed since originally including the package without updating the config file...?


I had a problem to remove Code first lib CTP5 that had dependences, uninstall did not return any message and did not remove anything. Delete references from packages.config that you need to remove. After that it will not show in nuget anymore and you can reinstall or continue without.


After using the VS IDE Manage NuGet Packages dialog or Package Manager Console you may have to manually remove solution files or other files on the file system that are part of the package not in the packages folder.

I was evaluating the Microsoft.AspNet.FriendlyUrls package which added a master page, a user control, a class code file and a packages.config file to my ASP.NET web application project / solution. I made the mistake to manually undo / remove these files from the solution before using the NuGet Packages dialog to remove the package. Everything got confused at that point.

As others have said, deleting the packages folder was the solution. But then I had to manually figure out the other files outside that folder that also should be deleted.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜