8

I am new to TeamCity and I have just installed it and set it up with subversion. I would like the TeamCity build number to be put in the output files, so that my Application.exe has the same build number.

How can I do this?

kasperhj
  • 10,052
  • 21
  • 63
  • 106

3 Answers3

11

There is now an assemblyinfo patcher built into teamcity. They call it a build feature: http://confluence.jetbrains.net/display/TCD65/AssemblyInfo+Patcher

Use that with the parameters mention or make your own e.g.: 1.2.%build.vcs.number%.1

James Woolfenden
  • 6,498
  • 33
  • 53
3

try this:

This is using Team City with MSBuild. If you're using Nant try this:

Community
  • 1
  • 1
Colin Pickard
  • 45,724
  • 13
  • 98
  • 148
  • Nice finds. Thanks. Often I compile locally, does this require me to have TC and MSBuild Community Tasks/NAnt installed locally as well as on the TC server? – kasperhj Jul 12 '11 at 13:14
  • This method doesn't change the AssemblyInfo.cs file until build time, so building anywhere else will not be affected. Obviously there will be no build number added if you build locally. – Colin Pickard Jul 12 '11 at 13:36
  • But won't it fail the build if I don't have the necessary build tools installed locally, or will it just ignore $(BUILD_NUMBER) etc.? – kasperhj Jul 12 '11 at 13:38
  • 1
    `$(BUILD_NUMBER)` is in the msbuild file. I don't know how you do your Team City builds but in my setup I don't use msbuild files for my local setup ( I just build with Visual Studio). if you do then you'll need to have separate files for local and build machine or something. – Colin Pickard Jul 12 '11 at 14:11
  • -1 should at least provide context that this is a lowest common denominator answer to the problem. TeamCity has an AssemblyInfo patcher build task, which is the easy path. – John Dhom Jan 04 '12 at 17:42
1

I run a powershell script after getting the sources from svn and before the build starts.

More or less like so.

http://jake.murzy.com/post/3099699807/how-to-update-assembly-version-numbers-with-teamcity

Loofer
  • 6,841
  • 9
  • 61
  • 102