Increment the build number automatically

Deadly 提交于 2019-12-04 11:37:26

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

  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:

  • 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%.

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.

Teamcity configuration build number is available to you in msbuild via $(BUILD_NUMBER). Leave your teambuild no to be the default {0}. I suggest you use this and edit the two assembly info files via a your own custom msbuild. You could keep a tokenised version of each file so that the version file contained 2.0.0.$(BUILD_NUMBER) in the version attribute and then use the extension pack detokenise to convert both (or any number of files for that matter). Still think you should have the same versioning on both projects though...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!