Export (0) Print
Expand All

Customizable Team Foundation Build Targets

MSBuild targets define how an 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. Build definitions include a project file that is named TfsBuild.proj. The project file can be associated with only one build definition, or with multiple build definitions. TfsBuild.proj imports the Microsoft.TeamFoundation.Build.targets file and provides values for various properties and item groups. You can customize the TfsBuild.proj file to override some of the extension point targets in the hierarchy. The targets file is located in <root>:\Program Files\MSBuild\Microsoft\VisualStudio\TeamBuild on the build agent.

Important noteImportant Note:

Do not modify the Microsoft.TeamFoundation.Build.targets file.

For more information about MSBuild targets, see MSBuild Targets.

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 that depend on when you must run your custom tasks during the build process.

NoteNote:

We do not recommend that you override other targets.

Target Name

Description

BeforeEndToEndIteration

Insert your task into this target to run custom tasks at the very start of the build process.

AfterEndToEndIteration

Insert your task into this target to run custom tasks at the end of the build process.

BeforeInitializeWorkspace

Insert your task into this target to run custom tasks before workspace initialization.

AfterInitializeWorkspace

Insert your task into this target to run custom tasks after workspace initialization.

BuildNumberOverrideTarget

Insert your task into this target to customize the build number or drop location properties. 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 task.

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 after 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 the 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.

BeforeCompileConfiguration

Insert your task into this target to run custom tasks before the compilation of an individual configuration.

BeforeCompileSolution

Insert your task into this target to run custom tasks before the compilation of an individual solution.

AfterCompileSolution

Insert your task into this target to run custom tasks after the compilation of an individual solution.

AfterCompileConfiguration

Insert your task into this target to run custom tasks after the compilation of an individual configuration.

AfterCompile

Called after compilation is completed. Insert your task into this target to run custom tasks after the code files are compiled. For an example, see Walkthrough: Configuring Team Build to Build a Visual Studio Setup Project.

BeforeGetChangesetsAndUpdateWorkItems

Insert your task into this target to run custom tasks before associating changesets and updating work items.

AfterGetChangesetsAndUpdateWorkItems

Insert your task into this target to run custom tasks after associating changesets and updating work items.

BeforeTest

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

BeforeTestConfiguration

Insert your task into this target to run custom tasks before the testing of an individual configuration.

AfterTestConfiguration

Insert your task into this target to run custom tasks after the testing of an individual configuration.

AfterTest

Called after the 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 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.

BeforeCreateWorkItem

Insert your task into this target to run custom tasks before work item creation.

AfterCreateWorkItem

Insert your task into this target to run custom tasks after work item creation.

BeforeOnBuildBreak

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

AfterOnBuildBreak

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

GenerateDocumentation

This is an empty target. Insert your task into this target to generate documentation during the build process.

Overriding Targets to Run Custom Tasks

The task code you write must be paired with a target and the built binaries must be available on the build computer, either by providing the source control path in the TfsBuild.proj file or by making the binaries available on the build computer itself. You must also register the custom task in the TfsBuild.proj file by declaring it using the UsingTask MSBuild element. For more information, see UsingTask Element (MSBuild). Lastly, deploy the DLL that contains the custom task on the build computer.

Important noteImportant Note:

Every build definition that is associated with the TfsBuild.proj file that you customize is affected by the change.

For an example of an end-to-end implementation of a custom task, see Walkthrough: Customizing Team Foundation Build with a Custom Task.

Order of Target Execution

The order of execution of the targets depends on the value of the CleanCompilationOutputOnly property. If CleanCompilationOutputOnly is true, the clean targets (BeforeClean, CoreClean and AfterClean) are executed after the get and label targets (BeforeGet, CoreGet, AfterGet, BeforeLabel, CoreLabel, and AfterLabel). If the CleanCompilationOutputOnly property is false, the clean targets are executed before the get and label targets. If CleanCompilationOutputOnly is true, only the intermediate assemblies are deleted from the sources directory during the CoreClean target execution. If this property is set to false, all of the sources directory will be deleted during CoreClean target execution.

The following table shows the ordered list of targets that are executed based on whether CleanCompilationOutputOnly is true or false. The targets that you can override are indicated.

CleanCompilationOutputOnly = true

CleanCompilationOutputOnly = false

  1. InitializeBuildProperties

  2. BeforeEndToEndIteration (can override)

  3. BuildNumberOverrideTarget (can override)

  4. InitializeEndToEndIteration

  5. BeforeInitializeWorkspace (can override)

  6. CoreInitializeWorkspace

  7. AfterinitializeWorkspace (can override)

  8. InitializeBuild

  9. BeforeGet (can override)

  10. CoreGet

  11. AfterGet (can override)

  12. BeforeLabel (can override)

  13. CoreLabel

  14. AfterLabel (can override)

  15. BeforeClean (can override)

  16. CoreCleanCompilationOutput

  17. AfterClean (can override)

  18. BeforeCompile (can override)

  19. CoreCompile (for each platform/configuration combination)

  20. BeforeCompileConfiguration (can override)

  21. CoreCompileConfiguration (for each solution to build)

  22. BeforeCompileSolution (can override)

  23. CoreCompileSolution

  24. AfterCompileSolution (can override)

  25. AfterCompileConfiguration (can override)

  26. AfterCompile (can override)

  27. BeforeGetChangesetsAndUpdateWorkItems (can override)

  28. CoreGetChangeSetsAndUpdateWorkItems

  29. AfterGetChangesetsAndUpdateWorkItems (can override)

  30. BeforeTest (can override)

  31. CoreTest (for each platform/configuration combination)

  32. BeforeTestConfiguration (can override)

  33. CoreTestConfiguration

  34. AfterTestConfiguration (can override)

  35. AfterTest (can override)

  36. GenerateDocumentation (can override)

  37. BeforeDropBuild (can override)

  38. CoreDropBuild

  39. AfterDropBuild (can override)

  40. AfterEndToEndIteration (can override)

  1. InitializeBuildProperties

  2. BeforeEndToEndIteration (can override)

  3. BuildNumberOverrideTarget (can override)

  4. InitializeEndToEndIteration

  5. BeforeInitializeWorkspace (can override)

  6. CoreInitializeWorkspace

  7. AfterInitializeWorkspace (can override)

  8. BeforeClean (can override)

  9. CoreClean

  10. AfterClean (can override)

  11. InitializeBuild

  12. BeforeGet (can override)

  13. CoreGet

  14. AfterGet (can override)

  15. BeforeLabel (can override)

  16. CoreLabel

  17. AfterLabel (can override)

  18. BeforeCompile (can override)

  19. CoreCompile (for each platform/configuration combination)

  20. BeforeCompileConfiguration (can override)

  21. CoreCompileConfiguration (for each solution to build)

  22. BeforeCompileSolution (can override)

  23. CoreCompileSolution

  24. AfterCompileSolution (can override)

  25. AfterCompileConfiguration (can override)

  26. AfterCompile (can override)

  27. BeforeGetChangesetsAndUpdateWorkItems (can override)

  28. CoreGetChangeSetsAndUpdateWorkItems

  29. AfterGetChangesetsAndUpdateWorkItems (can override)

  30. BeforeTest (can override)

  31. CoreTest (for each platform/configuration combination)

  32. BeforeTestConfiguration (can override)

  33. CoreTestConfiguration

  34. AfterTestConfiguration (can override)

  35. AfterTest (can override)

  36. GenerateDocumentation (can override)

  37. BeforeDropBuild (can override)

  38. CoreDropBuild

  39. AfterDropBuild (can override)

  40. AfterEndToEndIteration (can override)

The following is the list of targets that are executed when an error occurs during the execution of the CoreCompile target. The targets that you can override are indicated.

  1. SetBuildBreakProperties

  2. BeforeOnBuildBreak (can override)

  3. GetChangesetsOnBuildBreak

  4. BeforeDropBuild (can override)

  5. CoreDropBuild

  6. AfterDropBuild (can override)

  7. BeforeCreateWorkItem (can override)

  8. CoreCreateWorkItem

  9. AfterCreateWorkItem (can override)

  10. CoreOnBuildBreak

  11. AfterOnBuildBreak (can override)

Community Additions

ADD
Show:
© 2014 Microsoft