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

查看:2959
本文介绍了如何自动更新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).

所以我的问题是:什么是自动升级NuGet包而不使我的repo2 VCS​​的一个好方法? 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天全站免登陆