简体   繁体   English

Nuget Clean Package删除/安装

[英]Nuget Clean Package Remove/Install

I'd like to remove an entire nuget package, and cleanly install it in my project again. 我想删除一个完整的nuget包,并再次在我的项目中干净地安装它。

Sadly, for some reason it skips removing files that have been "modified", and then skips putting them in the project on reinstall, because they already exist. 遗憾的是,出于某种原因,它会跳过删除已经“修改”的文件,然后在重新安装时跳过将它们放入项目中,因为它们已经存在。

Is there any flag i can set to unconditionally remove every single trace of a nuget package, alternatively overwrite all existing files? 是否有任何标志我可以设置无条件删除nuget包的每一个跟踪,或者覆盖所有现有文件?

Thanks. 谢谢。

Unfortunately at the moment, NuGet does not do what you want. 不幸的是,目前,NuGet没有做你想做的事。 During the uninstall process, NuGet will only delete content files if they have not been modified. 在卸载过程中,NuGet将仅删除尚未修改的内容文件。 And as you've noticed, the update process will not update files that were modified either. 正如您所注意到的,更新过程不会更新已修改的文件。

The Uninstall-Package command does have a -Force option, but that is to "force" uninstall even if there are other packages that depend on this one. Uninstall-Package命令确实有一个-Force选项,但即使有其他依赖于这个的包也是“强制”卸载。

We can certainly file this as an issue and perhaps incorporate it into a future version. 我们当然可以将此作为一个问题提交,并将其合并到未来的版本中。

Another option would be to create a PowerShell script that will enumerate a package's contents, then allow you to delete all the content files. 另一种选择是创建一个枚举包内容的PowerShell脚本,然后允许您删除所有内容文件。 I'll see if there is a simple way to do this. 我会看看是否有一种简单的方法可以做到这一点。

BTW: Perhaps you can figure out a better way to extend the existing content file other than modifying it directly. 顺便说一句:也许您可以找出一种更好的方法来扩展现有的内容文件而不是直接修改它。 Especially since you're losing your changes when the package is updated. 特别是因为您在更新软件包时丢失了更改。

You can now do what you want! 你现在可以做你想做的! (finally) (最后)

You need to first update to the latest NuGet (I think this feature was added around April 2013). 您需要先更新到最新的NuGet(我认为此功能是在2013年4月左右添加的)。 Do this by going to Tools > Extensions and Updates and click on Updates to update nuget. 通过转到“ Tools > Extensions and Updates并单击“ Updates以更新nuget来执行此操作。

Then the -FileConflictAction parameter will allow you to overwrite files. 然后-FileConflictAction参数将允许您覆盖文件。

Install-Package Microsoft.jQuery.Unobtrusive.Validation -Version 2.0.30506.0 -FileConflictAction Overwrite

( PowerShell Command Reference for Install-Package ) 安装包的PowerShell命令参考

The NuGet Version 1.6 HAS a remove package function! NuGet版本1.6具有删除包功能! http://docs.nuget.org/docs/release-notes/nuget-1.6 http://docs.nuget.org/docs/release-notes/nuget-1.6

if the update of the extension fails (signatur missmatch), just uninstall and reinstall. 如果扩展的更新失败(signatur missmatch),只需卸载并重新安装。 this is a known problem. 这是一个已知问题。

I think this happened to me a few times. 我想这发生在我身上几次。 Go to the packages.config file that should be the root directory of your project and remove the insurgent (in your case the line with the package: SignalR). 转到应该是项目根目录的packages.config文件,并删除叛乱分子(在您的情况下,包含该行的行:SignalR)。 This will tell NuGet that the package was never installed. 这将告诉NuGet从未安装过该软件包。

Now you will be able to reinstall it through the repository, then uninstall it so everything is back to the way it was before you got into this mess. 现在,您将能够通过存储库重新安装它,然后将其卸载,以便一切都恢复到您进入此混乱之前的状态。 I am unsure how it is occurring. 我不确定它是如何发生的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM