30 Useful Team Build Properties

| 9 Comments

If you are going to get into the Zen of TFS Team Build, then at some point you are going to have to read the TeamBuild .targets file (located in %ProgramFiles%\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets).  The TeamBuild build scripts are usually extensions of this master build script.  In Orcas the script has has several revisions to make sure as many hooks are provided as possible, but extraordinary lengths have been gone to to make sure that scripts written to target the old (VS 2005) version of the file will still work with the new one.   The problem with all MSBuild scripts, and a problem that is shared with Nant and Ant scripts alike, is that they take a little bit of working out.  You cannot just pick up a script and read it from beginning to end due to the way that dependencies work in these process execution languages and the fact that you can have multiple entry points.  Fortunately, the TeamBuild .targets file is very well commented and there is also additional documentation available on MSDN listing the points you should start to look when hooking in your logic.

However, when you eventually override your first target to write a custom bit of code in the build process, you are going to need to know some properties that are available for you.  Below is my list of 30 build properties that you will find useful.  There are over 70 available if you read the target file you will find them all, these are just the ones that I find most useful - some to read the properties available, and some to override to easily alter the behavior of the build script.

Property Description Example
BuildDefinition Build Definition Name Team Build Example CI
TeamFoundationServerUrl The URL of the Team Foundation Server http://tfsserver:8080/
TeamProject Team Project build is running in TeamProject
SourceGetVersion Version to get when doing build C1234
BuildDirectory Working directory for build c:\buildworking\TeamProject\Team Build Example CI
BuildDefinitionName Name of build definition Team Build Example CI
BuildNumber identifies the name of the build, i.e., the build number Team Build Example CI_20070723.3
DropLocation Location of drop folder \\jeeves\drop\fixupload
MachineName Name of build machine buildserver.teamprise.com
RequestedBy User requesting build (in DOMAIN\Username format).  In a CI build, this will be less meaningful as it is a service user. Team Build System Account
RequestedFor User that build was requested for (in DOMAIN\Username format).  In a CI build this will be the user who performed the check-in that triggered the build DOMAIN\username
StartTime Build start date/time 07/23/2007 10:44:43
IncrementalGet Set this property to true to do an incremental get - this will override the CleanCompilationOutputOnly, SkipInitializeWorkspace, and ForceGet properties FALSE
IncrementalBuild Set this property to true to do an incremental build - this will override the SkipClean, SkipInitializeWorkspace, and ForceGet properties FALSE
SkipClean Set this property to true to skip the CoreClean target FALSE
SkipLabel Set this property to true to skip the CoreLabel target FALSE
SkipPostBuild Set this property to true to skip the PostBuild target FALSE
SkipGetChangesetsAndUpdateWorkItems Set this property to skip the CoreGetChangesetsAndUpdateWorkItems target, which calls the GenCheckinNotesUpdateWorkItems task FALSE
SkipDropBuild Set this property to true to skip the CoreDropBuild target FALSE
SkipWorkItemCreation Set this property to true to skip the CoreCreateWorkItem target FALSE
StopOnFirstFailure Set this property to true to stop Cleaning, Compiling, and/or Testing on the first failure encountered FALSE
SolutionRoot points to the root of the sources folder on build server c:\buildworking\TeamProject\Team Build Example CI\BuildType\..\Sources
BinariesRoot points to the root of the binaries folder on the build server c:\buildworking\TeamProject\Team Build Example CI\BuildType\..\Sources\..\Binaries
TestResultsRoot points to the root of the test results folder on the build server c:\buildworking\TeamProject\Team Build Example CI\BuildType\..\Sources\..\TestResults
WorkspaceName The name of the workspace that will be used for getting sources. Note: Workspace name can be up to 64 characters long - after that it will be truncated. $(COMPUTERNAME)_$(TeamProject)_$(BuildDefinition)
GetPopulateOutput Set this to true to populate the Gets, Replaces, and Deletes item group outputs of the Get task FALSE
LabelComment The comment used by the Label task Label created by Team Build
LabelName The label name used by the Label task.  By default the label name is set to $(BuildNumber) in the InitializeEndToEndIteration target. Team Build Example CI_20070723.3
OutDir The location of the output files in the build working directory. c:\buildworking\TeamProject\Team Build Example CI\BuildType\..\Sources\..\Binaries\Release\
BuildProperties all properties into a single string for simple passing to child MSBuild task invocations.  See also "EscapedBuildProperties", BuildAgentName=BuildServerAgent;BuildAgentUri=vstfs:///Build/Agent/1; BuildDirectory=c:\buildworking\TeamProject\Team Build Example CI; BuildDefinitionName=Team Build Example CI; BuildDefinitionUri=vstfs:///Build/Definition/1; BuildNumber=Team Build Example CI_20070723.3; ConfigurationFolderUri=vstfs:///VersionControl/VersionedItem/TeamProject%25252fTeamBuildTypes%25252fTeam%252bBuild%252bExample%252bCI%2526changesetVersion%253d5935%2526deletionId%253d0; ConfigurationFolderGetTime=07/23/2007 10:44:43; DropLocation=\\jeeves\drop\fixupload; MachineName=build.teamprise.com; MaxProcesses=1;Port=9191; RequestedBy=Team Build System Account; RequestedFor=DOMAIN\username; StartTime=07/23/2007 10:44:43

9 Comments

But remember, you cannot get the value of the "RequestedBy" in the MSBuild Script. Looks like you need to write a custom task : See:
http://blogs.msdn.com/gautamg/archive/2005/12/20/505863.aspx

Sudheer,

RequestedBy and RequestedFor are available inside the Team Build 2008 build scripts, so with TFS2008 you won't need that workaround.

Cheers,

Martin.

Thanks for posting this. Its very useful!

Cheers
Greg

RequestedFor can't be overridden right?
It's only there to query against?

thanks for this post. Relly useful!!!!

I've been knee-deep in TFS and MSBuild for the past couple of weeks, and Google keeps sending me back to your blog, where I am consistently delivered the tidbits and top tips I'm after. I really appreciate all the effort you've put into this site over the years and - as if it were ever in doubt - it's crystal clear why you are held in such high regard by the community. Thank you Martin!!

Is that any properties to skip log the new build number on Global List. We would like to ignore any CI build to Global list so we will have a clean filter on the bug work item found In build WI field.

Archives

Creative Commons License
This blog is licensed under a Creative Commons License.