Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assembly Versioning with TeamCity

I'm working on a C#/VB.Net project that uses SVN and TeamCity build server. A dozen or so assemblies are produced by the build. I want to control the assembly versions so that they all match up and also match the TeamCity build label.

I've configured TeamCity to use a build label of

Major.Minor.{Build}.{Revision}

Where Major and Minor are constants that I set manually, {Revision} is determined by the SVN repository version at checkout and {Build} is a TeamCity auto-incrementing build counter. So an example build label would be

2.5.437.4423

What techniques would you suggest to ensure that all of the assembly versions match the TeamCity build label?

like image 385
Tim Long Avatar asked Aug 03 '09 16:08

Tim Long


1 Answers

I'd suggest using TeamCity's AssemblyInfo patcher build feature:

http://confluence.jetbrains.net/display/TCD65/AssemblyInfo+Patcher

Just create your projects from VisualStudio, configure the build feature in the BuildSteps page (see http://confluence.jetbrains.net/display/TCD65/Adding+Build+Features), and as long as you keep the default AssemblyInfo.cs file, it will work.

This approach is working great for me.

Advantages:

  • Developers can build the solution in their machines.
  • You don't need to touch the .sln or .csproj files. It just works.
  • By using TeamCity variables you can easily make the version number match some other project's version, etc.

Disadvantages:

  • You can't easily switch to another CI server from TeamCity because you don't have a build script (but switching CI servers is like switching ORM or database: it is very unlikely and will require a lot of work anyway).
like image 196
Rodolfo Grave Avatar answered Oct 05 '22 23:10

Rodolfo Grave