If you read my first post on getting started with TeamCity, and my follow up post on moving to MSBuild you will have a lovely CI system that builds your solution each you commit your changes. Whilst this sounds fantastic, unfortunately of the assemblies that are built will all be versioned with the same version that is pulled from the AssemblyInfo. Luckily it isn't a major change to get MSBuild to update your solution files with the version number stored in TeamCity every time a build occurs by tweaking your MsBuild File: (and installing MsBuild Community Tasks)
<?xml version="1.0" encoding="utf-8" ?>
<Project DefaultTargets="ReleaseBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Message Text="Set the correct $(BUILD_NUMBER)" />
<MSBuild Projects="ProjectName.sln" Targets="Rebuild" />
This change uses the FileUpdate Task in MsBuild Community Tasks to be performed on the two specified files, AssemblyInfo.vb and AssemblyInfo.cs. The Regex will search for the word Version, followed by a valid four digit string version, and replace it with the build version configured in team city.
I use a Solution wide AssemblyInfo file called SolutionAssemblyInfo.vb or SolutionAssemblyInfo.cs to standardise Assembly Information across the solution by using a single shared file. You can Create this shared file in Visual Studio by Adding a New Item to the Solution Directly, and then after you have created it you link it into each project by clicking on Add existing in each project and pressing the Arrow on the 'Add' Button and selecting 'Add as Link' instead. This Shared Solution wide file contains the assembly info that is shared across the assemblies, each project will contain the link to shared assembly info file, and the existing assembly info file in the My Project folder.