如何自动将 NuGet 包更新到最新的可用版本 [英] How to automatically update NuGet packages to latest available version

查看:24
本文介绍了如何自动将 NuGet 包更新到最新的可用版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个存储库,我需要从另一个存储库中编译的库.我不想手动检查 repo1 以获取更新的库,然后复制/提交到 repo2,因为那很愚蠢.我有 repo1 在必要库的每个构建上构建 NuGet 包,并将它们发布到内部 NuGet 服务器.然后 repo2 中的项目可以引用这些 NuGet 包,并且一切都(几乎)正常工作.

I have two repositories, and I need compiled libraries from one repository in the other. I don't want to manually check repo1 for updated libraries, and copy/commit to repo2, because that is stupid. I've got repo1 building NuGet packages on each build of the necessary libraries, and publishing them to an internal NuGet server. Projects in repo2 can then reference these NuGet packages, and everything is (almost) working.

最后一个障碍是自动更新 repo2 项目中的 NuGet 包.由于我不知道 repo1 中的库何时会更新(而且我不应该这样做),我想在 repo2 中的项目上进行某种构建事件,该事件将自动更新 NuGet 包.我目前只有一个预构建事件,但由于 packages.config 文件包含已安装包的版本号,我不断在 repo2 中获取修改后的文件(packages.config 文件得到更新).

The one last hurdle to this is automatically updating the NuGet packages in repo2's projects. Since I don't know when the libraries in repo1 will get updated (and I shouldn't have to), I would like some sort of build event on the projects in repo2 that will automatically update the NuGet packages. I currently just have a pre-build event doing it, but since packages.config files contain the version number of the installed package, I keep getting modified files in repo2 (the packages.config files get updated).

所以我的问题是:在不破坏我的 repo2 VCS​​ 的情况下自动升级 NuGet 包的好方法是什么?ScottGu 说 这里(在评论中)可以将包升级挂钩到 CI 构建,但他没有具体说明如何以及我当前的解决方案是混乱的.有没有我缺少的内置方式?还是有更好的解决方法?

So my question is: what's a good way to automatically upgrade NuGet packages without mucking up my repo2 VCS? ScottGu says Here (in comments) that it's possible to hook package upgrades up to CI builds, but he doesn't specify how and my current solution is messy. Is there a built in way that I'm missing? Or any better work-arounds?

推荐答案

您可能可以利用 NuGet 包还原功能(这里有一些信息:http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages)

You could probably leverage the NuGet Package Restore feature (a bit of info here : http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages)

在项目构建时,它调用nuget.exe -install"从 packages.config 重新安装包.我还没有尝试过,但是您可以以相同的方式将更新命令添加到 nuget.targets 文件中.(您必须同时调用 nuget.exe 更新和现有的 nuget.exe 安装).

At project build, it calls "nuget.exe -install" to reinstall the packages from packages.config. I haven't tried it but you could add a Update command to the nuget.targets file in the same way. (You'd have to call both nuget.exe update and the existing nuget.exe install).

这篇关于如何自动将 NuGet 包更新到最新的可用版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆