|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
Team Foundation Build Tasks
The MSBuild tasks are contained in targets. These tasks provide the code that runs during the build process. MSBuild provides a library of common tasks. For more information, see MSBuild Task Reference.
The MSBuild .targets file for Team Foundation Build, Microsoft.TeamFoundation.Build.targets defines several default Team Foundation Build tasks that you can customize by setting properties in the TfsBuild.proj file. For example, the CoreGet target includes a Get task that enables you to retrieve a specific changeset for a build type. By default, the Get task retrieves the latest files. For more information about .targets files, see MSBuild .Targets Files.
The following tasks can be customized by modifying their properties.
Team Foundation Build Task
Synchronizes the sources on the build computer. It also raises log events to inform the logger of every file and version retrieved into the local workspace.
Labels all source files of a specified workspace.
Generates the list of all changesets and work items that were created or affected during a build. Labels are used to tag a particular build.
GetChangeSetsAndUpdateWorkitems target is invoked if the build is successful.
GetChangeSetsOnBuildBreak target is invoked if the build is not successful.
Creates a new work item for failures that occur during the build process. Also, it updates the Found In field in the work item with a link to the specific build number.
Creates a new workspace on the build computer.
Deletes the workspace created during the build execution. The actual files are not deleted from the build computer. If the specified workspace does not exist, DeleteWorkspaceTask issues a warning.
Creates a folder at a specified location to receive the built files. Also, it updates the build number.
Runs a set of tests during the build and publishes the results.
Inserts the build steps into the build.
Outputs the initial values for the build properties.
Sets any property on the build that can be set.
Converts the version control server items to local workspace items, and local items to version control server items.
ResolveSolutionPathsForEndToEndIteration and ResolveTestFilesForEndToEndIteration
To modify the tasks defined in the definition file Microsoft.TeamFoundation.Build.targets, examine the properties of the task you want to modify, and then specify those properties in the TfsBuild.proj file for your Team Foundation Build build type. The CreateNewWorkItem task is defined as follows.
<!-- Create WorkItem for build failure --> <CreateNewWorkItem BuildId="$(BuildNumber)" Description="$(WorkItemDescription)" TeamProject="$(TeamProject)" TeamFoundationServerUrl="$(TeamFoundationServerUrl)" Title="$(WorkItemTitle)" WorkItemFieldValues="$(WorkItemFieldValues)" WorkItemType="$(WorkItemType)" ContinueOnError="true" />
To customize the work item that is created when a build fails, set the WorkItemFieldValues in the TFSBuild.proj file:
The following assumes that the Areapath and IterationPath properties have also been set.
<WorkItemFieldValues>Area Path=$(AreaPath);Iteration Path=$(IterationPath);Severity=1;Priority=0;Symptom=build break;Steps To Reproduce=Start the build using Team Build;Source=Development;How Found=Build Break;Assigned To=Active</WorkItemFieldValues>