Customizable Team Foundation Build Targets

MSBuild targets define how a MSBuild project is built. The Microsoft.TeamFoundation.Build.targets file defines the target hierarchy and a set of predefined MSBuild tasks and targets for Team Foundation Build used for all Team Foundation Build types. Each Team Foundation Build build type includes a project file that is named TfsBuild.proj. TfsBuild.proj imports the Microsoft.TeamFoundation.Build.targets file and provides values for various properties, item groups, and potentially overrides some of the extension point targets in the hierarchy.

Targets that can be Customized with Tasks

Tasks are contained in targets. Tasks provide the code that runs during the build process. The following table lists all the Team Foundation Build targets that are defined for extensibility. Insert your tasks into one of these targets depending on when you must run your custom tasks during the build process.

Note

We do not recommend that you extend other targets.

Target Name

Description

BeforeEndToEndIteration

Insert your task into this target to run tasks before the EndToEndIteration target.

AfterEndToEndIteration

Insert your task into this target to run tasks after the EndToEndInteration target.

BuildNumberOverrideTarget

Used to override a target to customize the build number. The task you write must create an output property called BuildNumber.

BeforeClean

Called before clean is tried. Insert your task into this target to run pre-clean custom target.

AfterClean

Called after clean is completed. Insert your task into this target to run post-clean custom tasks.

BeforeGet

Called before sources are retrieved from source control. Insert your task into this target to run custom tasks before sources are retrieved.

AfterGet

Called after sources are retrieved. Insert your task into this target to run custom tasks before sources are retrieved.

BeforeLabel

Called before sources are labeled. Insert your task into this target to run custom tasks before the Label target.

AfterLabel

Called after labeling is completed. Insert your task into this target to run custom tasks after the Label target.

BeforeCompile

Called before compilation is started. Insert your task into this target to run custom tasks before the code files are compiled.

Called before tests are run. Insert your task into this target to run custom tasks before the Test target.

AfterTest

Called after testing is completed. Insert your task into this target to run custom tasks after the Test target.

BeforeDropBuild

Called before saving the built binaries, build log files, and test results to the build-drop directory on the release server. Insert your task into this target to run custom tasks before the built files are saved to the drop-directory.

AfterDropBuild

Called after dropping the built binaries, build log files, and test results to the release server. Insert your task into this target to run custom tasks after the built files are saved to the drop-directory.

BeforeOnBuildBreak

Called before creating a work item on the build break. Insert your task into this target to run custom tasks before the BuildBreak target.

AfterOnBuildBreak

Called after a work item is created on the build break. Insert your task into this target to run custom tasks after the BuildBreak target.

Inserting Tasks into the Targets

The task code you write must be paired with a target. For more information, see How To: Write a Task. To write a custom task you must follow these steps.

Write the task code, and check it into source control.

Note

It is good coding practice to check task code into source control, but it is not absolutely necessary.

Register the custom task in the TfsBuild.proj file by declaring it using the UsingTask MSBuild element. For more information, see UsingTask Element (MSBuild).