The Microsoft.TeamFoundation.Build.Workflow.Activities.UpdateBuildNumber activity in your build template (e.g. DefaultTemplate.xaml) is what does the work of transforming your build number format string. It takes any of the parameters listed here, however, the version (your changeset or label) is not one of the supported tags.
One workaround I've found that does not require custom code is to edit the BuildNumberFormat argument immediately before the Update Build Number activity uses it.
- Open up the xaml template using the GUI editor and find the Update Build Number activity at the top.
- Find the Primitives -> Assign activity in the Toolbox. Drag and drop that just above the Update Build Number.
- Edit the Assign activity to assign the value
String.Format("$(BuildDefinitionName)_$(Date:yyyyMMdd)_{0}$(Rev:.r)", BuildDetail.SourceGetVersion)
to BuildNumberFormat
. The SourceGetVersion will pull the changeset number or label used to trigger the build. If nothing is specified in the Get Version dialog when you're queuing your build then the changeset number is used by default (e.g. C16044).