BUILD_NUMBER and build counter


I need to strongly name my assemblies and working for past companies I remember the pain of explicitly versioning assemblies with build numbers. I'd like to copy the model that Microsoft use for example for the .Net framework DLLs. Once it is released, the version is fixed (AssemblyVersion), and this makes XCopy or hot fixing much easier later. However, I think it would be a good idea in the AssemblyFileVersion or AssemblyDescription to still have the build count.

I'd also like to use the build count to name my zip file at the end of the build process.

So, in TeamCity I have explicitly declared the version number as 1.0.09 and I can retrieve this in my build script (MSBUILD) as BUILD_NUMBER. Is there anyway I can populate the build count into a variable? So I could do something like:
AssemblyVersion="$(BUILD_NUMBER)" AssemblyFileVersion="$(BUILD_NUMBER) ($(BUILD_COUNT))"/>

Any tips about strong name assemblies (and avoiding pain) and doing this in TeamCity would be a great help.

Many thanks

Comment actions Permalink

Thinking about this, I suppose an option would be to pass in 1.0.09.{} for the BUILD_NUMBER and then somehow, in my MSBUILD script strip out the last section and store that in a variable.

I have never done string or variable manipulation in MSBUILD though!


Comment actions Permalink

you can get the current build number like this :

Comment actions Permalink

Did you guys manage to work out how to strip out the build counter from the $(BUILD_NUMBER)? I've been trying to directly reference the build counter but I can't find the object name.

Has anyone done this before?

Comment actions Permalink

I'm new to Teamcity and MSBuild, but it seems we're having similar problems.

Can you expand on how you pass the build number into MSBuild?

Do you do this by declaring a property in the command line area of your build runner?


Please sign in to leave a comment.