Mathias Olausson [MVP]

Archive for March, 2016

Versioning files in TFS Build (vNext)

without comments

 

In my DevOps and Continuous Delivery presentations I’m always including a step in the build process where source files are updated with the current build number. This gives us an easy way to correlate the produced package to the build it came from, which is great for traceability.

Enough people have asked for the script so I feel I should post it here. It’s really nothing special, just a lightly customized version of the original sample script Andy Lewis wrote a long time ago. The sample comes from mine and Jakob’s book on Continuous Delivery so make sure to get a copy if you want more context.

The script will apply a version to the source files, for instance updating AssemblyInfo attributes like this:

image

Our script will also update the version number for database projects (DACPAC packages) and Android manifest files. It’s easy to extend the script to do the same for Wix projects (MSIs) or C++ (RC) files following the same principles.

All you need to do to add it to your source code repository and use a PowerShell build step to run the script. In our example you need to pass the build source directory and the build number to the task:

image

Download the complete script here (and rename it to .ps1).

Written by Mathias Olausson

March 27th, 2016 at 1:36 pm