卸载 NuGet 包时出现问题

发布于 2024-11-18 19:37:13 字数 397 浏览 3 评论 0原文

我正在尝试卸载 NuGet 安装的一些软件包。根据此处描述的文档,当我选择已安装的软件包时,我应该会看到一个卸载按钮(下面的第一个屏幕截图)。但是,我只看到一个管理按钮(下面的第二个屏幕截图)。谁能告诉我如何卸载软件包?

NuGet 文档屏幕截图

我的截图

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

深爱成瘾 2024-11-25 19:37:13

如果向下滚动到管理已安装的包您链接到的 NuGet 文档页面的 部分将看到“管理”按钮和说明。

NuGet 1.4 中引入了一项新功能,允许您选择解决方案解决方案资源管理器并一步添加/删除多个项目中的包。以前,您必须在解决方案资源管理器中选择每个项目,并一次从每个项目中添加/删除一个包。

如果单击“管理”按钮,将显示“选择项目”对话框,您可以在其中取消选中要从中卸载 NuGet 包的项目。

在此处输入图像描述

如果您在解决方案资源管理器中选择项目而不是解决方案,则可以从所选项目中添加/删除包项目。在这种情况下,您只会看到“安装”和“卸载”按钮。

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.

花之痕靓丽 2024-11-25 19:37:13

最后,我发现我必须手动编辑 .sln 解决方案文件并删除这些行:

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

删除解决方案文件中的上述行后,这些包在 NuGet 包窗口“已安装的包”页面中消失。只剩下一个软件包,我现在可以看到“卸载”按钮。

在此处输入图像描述

编辑:
我还必须删除解决方案目录中的包文件夹。

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.

无畏 2024-11-25 19:37:13

有时,存在不允许卸载软件包的依赖项,但您无论如何都需要这样做(即,如果您无意中安装了具有依赖项的软件包的两个不同版本)。

发生这种情况时,卸载软件包的唯一方法是强制卸载,而这只能通过软件包管理器控制台来完成。

在进入控制台之前,您应该打开“管理 NuGet 包”窗口,并记下包的 ID 和版本,当您单击包时,该 ID 和版本将显示在右侧窗格中。

然后,您可以关闭“管理”窗口,打开控制台(程序包管理器控制台),然后运行以下命令:

uninstall-package -Id YourPackageId -Force -Version YourPackageVersion

注意 -Force 参数。例如,

uninstall-package -Id Unity -Force -Version 3.0.1304.0

此命令允许在与版本 2 并行安装时卸载版本 3,而这不能通过“管理”窗口完成。

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.

百善笑为先 2024-11-25 19:37:13

我最近也有类似的问题。我的项目工作正常,但我无法再通过 NuGet 包管理器添加或删除任何包,因为 EnterpriseLibrary 5.0.505 在源中显示为缺失。但尝试恢复或删除它失败,并出现错误“无法找到包‘EnterpriseLibrary’的版本‘5.0.505.’”。

我将此追溯到packages.config 文件中的以下引用:

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

将此与我最近添加包的其他解决方案进行比较,我将其更改为以下内容,这解决了问题:

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

我从未编辑过任何package.config 文件手动,所以我不知道不匹配是如何发生的。也许引用发生了变化,因为最初包含包而没有更新配置文件......?

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...?

卖梦商人 2024-11-25 19:37:13

我在删除具有依赖性的 Code First lib CTP5 时遇到问题,卸载没有返回任何消息,也没有删除任何内容。从packages.config 中删除您需要删除的引用。之后它将不再显示在 nuget 中,您可以重新安装或继续。

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.

梨涡 2024-11-25 19:37:13

使用 VS IDE 的“管理 NuGet 包”对话框或包管理器控制台后,您可能必须手动删除解决方案文件或文件系统上属于包的一部分但不在包文件夹中的其他文件。

我正在评估 Microsoft.AspNet.FriendlyUrls 包,该包向我的 ASP.NET Web 应用程序项目/解决方案添加了母版页、用户控件、类代码文件和 packages.config 文件。在使用 NuGet Packages 对话框删除包之前,我错误地从解决方案中手动撤消/删除这些文件。那时一切都变得混乱了。

正如其他人所说,删除软件包文件夹是解决方案。但后来我必须手动找出该文件夹之外的其他文件也应该删除。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文