Saturday, April 2, 2016

How to define build variables like SourcesDirectory, BinariesDirectory, TestResultsDirectory in TFS 2013 Default Build Template (TfvcTemplate.12.xaml)


In this post I will explain the steps to create build variables like SourcesDirectory, Binaries Directory, and TestResultsDirectory in TfvcTemplate.12.xaml.
By default we will not be able to use above variables in TFS 2013 default build template as how it’s there in TFS 2012/TFS 2010.
In order to get all these variable with proper path follow below steps.
1.      Download TfvcTemplate.12.xaml file from TFS and add the file to Source Control.  
2.      Create variable named SourcesDirectory, BinariesDirectory and TestResultsDirectory.
Open TfvcTemplate.12.xaml file and click on Run on agent workflow and then on Variable below the page.
Now create three variables named SourcesDirectory, BinariesDirectory and TestResultsDirectory as shown below. 

3. Now Open Toolbox (View -> Toolbox) and search for GetEnvironmentVariable activity.


4.      Select GetEnvironmentVariable<T> activity under Team Foundation build Activities and drag and drop it to TfvcTemplate.12.xaml  after the activity Update build number, on pop up change the type to String.




5.      Select the activity on the TfvcTemplate.12.xaml file and open properties window.
Change the property values as below.
 
Name: Microsoft.Teamfoundation.Build.Activities.Extensions.WellKnownEnvironmentVariables.SourcesDirectory
DisplayName: Get Sources Directory
Result: SourcesDirectory
6.    Add two more GetEnvironmentVariable<T> activities for TestResultsDirectory and Binariesdirectory with type String and set the property values as below respectively.

Property values for TestResultsDirectory
Name:
Microsoft.TeamFoundation.Build.Activities.Extensions.WellKnownEnvironmentVariables.TestResultsDirectory
DisplayName: Get Test Results Directory
Result: TestResultsDirecotry

Property values for BinariesDirectory
Name: Microsft.TeamFoundation.Build.Activities.Extensions.WellKnownEnvironmentVariables.BinariesDirectory
DisplayName: Get Binaries Directory
Result: BinariesDirectory
7. Save the changes and then check-in to the server.





 

No comments:
Write comments