自动递增的版本号 [英] Increment the build number automatically

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

问题描述

我有两个项目的解决方案。一个是3.0.0版。*和另一个是2.0.0。*。我建立我使用的MSBuild脚本的团队市的解决方案。我怎样才能版本字符串的版本号部分注入的AssemblyVersion属性离开major.minor.patch于开发时定义。

I have two projects in solution. One is version 3.0.0.* and the other is 2.0.0.*. I build my solution on Team City using an MSBuild script. How can I inject the build number portion of the version string into the AssemblyVersion attribute leaving the major.minor.patch as defined at dev time.

要换个方式,我想手动控制major.minor.patch(和专业会跨库不同的解决方案),但自动递增的版本号。

To put it another way I want to manually control major.minor.patch (and the majors will differ across libs in the solution) but auto increment the build number.

推荐答案

的TeamCity将自动为您管理的属性的AssemblyVersion,但也有一些注意事项:

TeamCity will automatically manage the AssemblyVersion attributes for you, but there are a few caveats:

  1. 这将完全覆盖现有​​的值。
  2. 这将更新的所有的AssemblyVersions的解决方案,因此,如果你是绑保持不同的项目版本相同的解决方案,这可能不适合你。
  1. It will totally overwrite the existing value.
  2. It will update all AssemblyVersions in the solution, so if you are tied to keeping different project versions in the same solution, this may not work for you.

通过这些警告,这里是我们如何对其进行设置:

With those caveats, here's how we've set it up:

  • 常规设置的生成配置的,修改版本号格式为:%版本%。{0 }
  • 构建参数的定义%版本%为您major.minor.patch。
  • 生成步骤的,滚动到屏幕的底部,然后点击添加构建功能的。选择程序集信息补丁。确保大会版本格式被填写为%build.number%
  • In the General Settings of your build configuration, change the Build number format to %version%.{0}
  • In your Build Parameters define %version% as your major.minor.patch.
  • In your Build Steps, scroll to the bottom of the screen and click Add Build Feature. Select AssemblyInfo patcher. Make sure the Assembly version format is filled in as %build.number%.

就是这样。 TeamCity的将更新所有组件的相关信息,以major.minor.patch.build由%版本%定义和建立柜台,然后自动恢复这些变化作为构建的最后一步。

And that's it. TeamCity will update all your assembly infos to major.minor.patch.build as defined by the %version% and build counter, and then automatically revert those changes as the very last step of the build.

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

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