NuGet:自动迁移对包的引用
我有一个包含约 50 个项目的中型解决方案,其中许多项目引用了 nuget 中提供的多个程序集。我真的很喜欢 nuget 的想法,并且想进行切换,但我想避免手动重新执行所有引用。
有没有办法自动将解决方案中所有项目的手动引用“升级”为 nuget 引用?
I've got a medium sized solution with ~50 projects and many of those projects reference multiple assemblies available from nuget. I really like the idea of nuget and would like to switch, but I'd like to avoid having to re-do all the references manually.
Is there a way to automatically "upgrade" manual references to nuget references over all projects in a solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单的方法是编写一个 powershell 脚本,使用 DTE 查看项目中的引用(这可以使用 NuGet powershell 窗口完成),然后查找匹配的包。这不是一个完美的解决方案,但它可以工作。
The easiest way would be to write a powershell script that looked at your references in the project using DTE (this can be done with the NuGet powershell window) and then looks for a matching package. It's Not a perfect solution but it could work.
您必须从 nuget.org 中提取包(不仅仅是元数据,还包括元数据和文件),并创建从所有程序集到包含这些程序集的包的反向映射。然后,您可以列出潜在的软件包候选者列表(可能有一些重叠)。一旦您列出了该列表,安装它们就像安装一样简单。
我们实际上为此提交了一个错误,但目前它在优先级列表中并不是很高。
You'd have to pull down the packages (not just metadata but metadata and files) from nuget.org and create a reverse mapping from all of the assemblies to packages that contained those assemblies. Then you could come up with a list of potential candidates for packages (there could be some overlap). Once you came up with that list it's as simple as installing them.
We actually filed a bug for this but it's not very high on the list of priorities right now.