Thursday, December 2, 2010

Variables available for the Workflow Foundation inside your Build Process Template

I might not be looking properly, but as per today, I did not find a large amount of information on the various parameters available for the Workflow Foundation inside your Build Process Template

For instance, just search for       "BuildDetail.DropLocation" BuildDirectory
 in Google, I only get 42 results. BUT thoses 2 parameters are essentials to my Workflow !

Update : The complete documentation on "Team Foundation Build Activities" is now available (Dec 9th  2010) http://msdn.microsoft.com/en-us/library/gg265783.aspx

Here are a list of other handy parameters that I use :
  • this:Process.BuildNumberFormat=["$(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r)"]



In C#, we have :
BuildDetail.DropLocation = "\\MyBuildServer\TFSDropBuild\Dev_Night\Dev_Night_20101202.6"

In order to have the name of the last sub-folder, you could use a quick and dirty trick (I hope there's a better solution somewhere hidden in the MSDN) :
Arguments = BuildDetail.DropLocation + " " + BuildDetail.DropLocation.Substring(BuildDetail.DropLocation.LastIndexOf("\") + 1)


Note : Even if it is not obvious, you can write some code in the "FileName" field. Warning, it'll look like you can write C# code (since the SubString(), '+' operator, etc... works) BUT you have to write that as a VB.Net expression, for instance :

  • "Hello World.This works".Split(Convert.ToChar("."))(0)



Alternatively, you could use native TFS property such as BuildDetail.BuildDefinition.Name if needed.
Another "Friend" string available is :

  • SourcesDirectory 

that replaces the need for doing :

  • BuildDetail.DropLocation.Split(Convert.ToChar("\"))(4).ToString()


Here is the detail of the POC Batch file to make sure that the expression in the "FileName" field works, with input parameters sent by WF4 :

REM Create a unique identifier
SET T=%time:~0,5% 
SET fileName=.%T::=-% 


REM %1 is for instance \\MyBuildServer\TFSDropBuild\Dev_Night\Dev_Night_20101202.6
DIR *.* > %1\myNewCreatedFile_%fileName%.txt
DIR *.* > %1\myNewCreatedFile_%2_%fileName%.txt

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.