Tuesday, August 17, 2010

Where's the Build Number, using MSBuild with VSTS 2010

I wanted to key the our assembly versions using the VSTS build number I quickly found the solution is not as simple as it seems. At first I thought this property would be a first class member of the IBuildDetail class making it easily accessible in the VSTS workflow but, it's not. After popping open the UpdateBuildNumberActivity I found the build number is actually extracted from the IBuildDetail.Uri. Use the format below in your MsBuild task to gain access to the BuildID and the SourceGetVersion. While the SourceGetVersion may return a sequential change set number (C123) it is not guaranteed to be numeric so it's probably not a good fit for the revision part of your version number. You may consider adding it to your AssemblyConfiguration attribute or AssemblyInformationalVersion attribute. Connecting the change set or source version to the assemblies generated may prove to be useful in troubleshooting version related issues later on.

String.Format("/p:SkipInvalidConfigurations=true /p:BuildID=""{1}"" /p:SourceGetVersion=""{2}"" {0}", MSBuildArguments, LinkingUtilities.DecodeUri(BuildDetail.Uri.ToString()).ToolSpecificId, BuildDetail.SourceGetVersion)

No comments:

Post a Comment