Updating assembly file versions using AssemblyInfo patcher

I'm using TeamCity v9. I'm trying to update the assemblyinfo using the AsemblyInfo patcher build feature. However this doesn't seem to be working. I'm not sure if I'm using it correctly.

I've created a new Configuration Parameter called Major.Minor and set this to 12.13. I've added the AssemblyInfo patcher as a Build Feature and set this to update the version to %system.build.number% in Assemblyinfo files. Under General Settings I've set the Build number format to %Major.Minor%.0.%build.counter%.

The build number that is displayed in TeamCity against the build correctly shows the expected build number (12.13.0.1, 12.13.0.2 etc). But the assembly versions that appear when you right click on the assembly and go to Properties are not showing these version numbers.

I've read through the documentation but can't see what I'm doing wrong. How do I update the AssemblyVersion, AssemblyFileVersion and AssemblyInformationalVersion with the TeamCity build number?

TIA

3 comments
Comment actions Permalink

Hello Dominic,

This feature works only for "standard" projects, i.e. created by means of the Visual Studio wizard, so that all the AssemblyInfo files and content have a standard location. Is your AssemblyInfo.cs located in /properties subfolder? Do you have a line in your AssemblyInfo.cs file that defines AssemblyInformationalVersion? It should look like this: [assembly: AssemblyInformationalVersion("1.0.0.0")].

0
Comment actions Permalink

Hi Alina

We keep the assembly version numbers in a non standard file called AssemblyVersion.cs so I'm pretty sure this is the issue. We use AssemblyInfo.cs purely for the assembly description information which will differ between different assemblies. We store the assembly version number in a single file called AssemblyVersion.cs that is shared among al projects in the solution.

With that in mind, how would we pass the TeamCity build number %system.build.number% to our MSBUILD script? I think this is the best option available to us.

TIA

0
Comment actions Permalink

Since TeamCity 9.1 File Content Replacer build feature is available. It changes files for the duration of the build and reverts changes when the build is finished (the same as AssemlyInfo Patcher does). However it is more flexible, and allows to change a wide range of values in files specified by the user. Please try it.


For MSBuild (Visual Studio 2005/2008 Project Files) use $(<property name>). Note that MSBuild does not support names with dots ("."), so you need to replace "." with "_" when using the property inside the build script. Please find more details here.

0

Please sign in to leave a comment.