生成的MSBuild的版本号 [英] Generating version number in MSBuild

查看:1334
本文介绍了生成的MSBuild的版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个维克斯安装一个C#解决方案和MSBuild的构建脚本。我们正处在从SVN迁移到Git的过程。

由于我们的版本号的第四部分,我们想要的东西,每个版本上升。到现在为止,我们已经使用了SVN版本号。该脚本的MSBuild定义的ProductVersion属性,它包含SVN版本号作为最后的四个数字的内部版本的。但是,我们不能使用了,因为我们不会使用SVN了。

我一直试图找到一种替代SVN版本号,但我想不出用什么。

  • 詹金斯规定,我可以用一个版本号,但我不想以配合我们的版本控制系统,詹金斯。

  • 詹金斯还提供了一个时间戳,但它不符合微软的版本号的限制:它的字母数字和一种长的,而在版本4号应介于0到65535的整数。

  • 我们可以设置的AssemblyVersion为1.0。*,让.NET填写休息。这适用于我们的组件,但我不能找到一种方法,注入到这一点维克斯。我们可以从组件中的一个取一次它的建成,但是我们的MSBuild脚本使用<的MSBuild> 任务来构建整个解决方案的一次,所以我们就完蛋了在catch-22在这里我们需要运行<的MSBuild> 所以它可以编译,我们可以用它来获取生成的版本号的组件,但为了执行<的MSBuild> ,我们首先需要有一个编译的程序集,这样我们就可以从中提取生成的版本号

  • 我可以在编译的东西(东西)的MSBuild的文件添加一个单独的目标,并从版本号,然后做了&LT实际调用;的MSBuild> 任务。但是,这只是感觉错了。

此外,我真的不关心数字是多少,只要它每次构建而递增。基于时间戳的东西就可以了。任何想法?

解决方案

包含的的MSBuild社区任务任务名为<一个href="https://github.com/loresoft/msbuildtasks/blob/master/Source/MSBuild.Community.Tasks/Version.cs"相对=nofollow>版时,它提供了一些算法以生成版本号。这是很容易使用和定制。

恕我直言,最好是选用一些是关系整个SDLC,这样你就可以跟踪你的产品部署到构建结果,而这些到VCS,等等。我会建议使用詹金斯集结号,克里斯托弗画家一样。

We have a C# solution with a WiX installer and an MSBuild build script. We're in the process of migrating from SVN to Git.

As the fourth part of our version number, we want something that ascends with each build. Until now, we've used the SVN revision number for that. The MSBuild script defines a ProductVersion property, which included the SVN revision number as the final of the four numbers of the build version. However, we can't use that anymore, as we won't be using SVN anymore.

I've been trying to find a replacement for the SVN revision number, but I can't figure out what to use.

  • Jenkins provides a build number that I could use, but I don't want to tie our versioning system to Jenkins.

  • Jenkins also provides a timestamp, but it doesn't comply with Microsoft's version number restrictions: it's alphanumeric and kind of long, while the 4th number in the version should be an integer between 0 and 65535.

  • We can set the AssemblyVersion to 1.0.* and let .NET fill in the rest. This works for our assemblies, but I can't find a way to inject this into WiX. We can fetch it from one of the assemblies once it's built, but our MSBuild script uses the <MSBuild> task to build the whole solution at once, so we're stuck in a Catch-22 where we need to run <MSBuild> so it can compile an assembly that we can use to fetch the generated version number, but in order to run <MSBuild>, we first need to have a compiled assembly so that we can fetch the generated version number from it.

  • I could add a separate Target in the MSBuild file that compiles something (anything) and get the version number from that, and then do the actual call to the <MSBuild> task. But that just feels wrong.

Again, I don't really care what the number is, as long as it increments with every build. Something based on a timestamp would be fine. Any ideas?

解决方案

The MSbuild Community Tasks contains a task named Version, it provides some algorithms to generate version numbers. It is very easy to use and customizable.

IMHO, it is better to use a number that ties your entire SDLC, so you can trace your deployed product to the build results, and these to the VCS, and so forth. I would recommend using jenkins build number, as Christopher Painter did.

这篇关于生成的MSBuild的版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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