How to modify the TFS 2013 default build process template (GitTemplate.12.xaml & TfvcTemplate.12.xaml) to enable releasing from a build
Release Management provides the option to trigger a release from a build. But to use this feature, some additional logic has to be added to the default build process template. This article details how to make the necessary modifications.
If you are currently using the TFS 2013 default build process template
If you are using the TFS 2013 default build process template all you need to do is use the corresponding release management build process template.
- If using GitTemplate.12.xaml then use ReleaseGitTemplate.12.xaml.
- If using TfvcTemplate.12.xaml then use ReleaseTfvcTemplate.12.xaml.
If you are currently using a customized TFS 2013 build process template
If you have customized the TFS 2013 default build process template (GitTemplate.12.xaml or TfvcTemplate.12.xaml), then you can use the snippets file (ReleaseTemplate.12.Snippets.xaml) to help you integrate the release-specific customizations into your own custom build process template.
Modifying your own custom build process template
The snippets file only contains sections with start / end markers to indicate which parts to copy.
The following is a sample section with start / end tags that is surrounded by some context.
<!– RM : START –>
<x:Property Name=”ConfigurationsToRelease” Type=”InArgument(s:String)” />
<x:Property Name=”ReleaseBuild” Type=”InArgument(x:Boolean)” />
<x:Property Name=”ReleaseTargetStage” Type=”InArgument(x:String)” />
<!– RM : END –>
Where <x:Members> … </x:Members> indicate the context and everything between the start / end tags indicates what to copy as is (yellow).
The only exception is the Activity element, where you will need to copy the attributes in the snippets file and add them to your custom build process template, without removing any existing attributes.
<Activity this:Process.ReleaseBuild=”False” xmlns:mtc=”clr-namespace:Microsoft.TeamFoundation.Client;assembly=Microsoft.TeamFoundation.Client” xmlns:mw=”clr-namespace:Microsoft.Win32;assembly=mscorlib” xmlns:sco=”clr-namespace:System.Collections.ObjectModel;assembly=mscorlib”>
Using the Release Management build process template
Consider the following when using the Release Management build process template.
- When using the functionality to automatically trigger Releases from a Build, you will need to install a Release Management client on your TFS Build Server. After installation, restart the TFS Build Services.
- While editing the Build Definition, Set the Release Build parameter to TRUE, to indicate that you want the build to be released.
- Specify the Target Stage for the Release in the Release Target Stage parameter. Leave blank to allow the Release to go through all the Stages defined in the Release Path. The check is case sensitive so make sure to match the name of the Target Stage verbatim.
- Ensure the Release Template is configured to match the Build Definition and the property Can Trigger a Release from a Build? is set.
For more clarity on points (2) and (3) above please see the sample image below.