How to: Modify the Scope of Changesets and Work Items Associated With a Build Type
Changeset and work item association in Team Foundation Build are controlled by supplying labels to the GenCheckinNotesUpdateWorkItems task. The labels used are the label generated during the last successfully completed build and the label generated during the current build. The changesets associated with the build include:
The items in the label generated by the last successfully completed build.
The items in the label generated by the current build.
The changesets created anytime between the previously successful build and the current build.
The work items associated with the build are those associated with all these changesets.
This topic explains the steps that you must follow to override the CoreLabel target to change what is labeled, and therefore to control what changesets and work items are associated with build.
Before you override the CoreLabel target, you must have the following:
Access to the TFSBuild.proj file of the build type you want to customize.
Each team build type is defined by a TFSBuild.proj file that is located in the folder $/MyTeamProject/TeamBuildTypes/MyBuildName in Team Foundation source control. MyTeamProject is the name of your team project and is the root node of all your team project sources. MyBuildName is the name that you gave to your build type. For more information about how to create Team Foundation Build build types, see.
A local workspace that contains your team project files and the build files on the local computer.
For more information, seeand .
The appropriate security permissions. For more information, see the following section.
To perform this task, you must have the Administer a build and Administer workspaces permission set to Allow. You must also have the Check in and Check out permissions set to Allow. For more information, see.
Getting a Local Copy of the TFSBuild.proj File
Before you change the TFSBuild.proj file that defines your build type, you must get a local copy.
To get a local copy of TFSBuild.proj file
On the View menu, select Other Windows, and then select Source Control Explorer.
In Source Control Explorer, click Workspaces on the toolbar, and then select your workspace from the list.
Open a team project folder that contains your build type, expand the TeamBuildTypes folder.
Right-click the TFSBuild.proj file, and select Get Latest Version to copy the latest version of the file.
For more information, see.
Overriding the CoreLabel Target in the TFSBuild.proj File
To specify the scope of the files that are built, override the Label task in the CoreLabel target.
To override the CoreLabel target
Check out the TFSBuild.proj file and open it in the Visual Studio XML-editor.
For more information, see.
Define a value for a new property GetChangesetForFolder. Add the PropertyGroup definition to the end of the TFSBuild.proj file, before the closing </project> tag.
</ItemGroup> <PropertyGroup> <GetChangesetForFolder>Component1</GetChangesetForFolder> </PropertyGroup> </Project>
The folder defined for GetChangesetForFolder must not include the team project folder. For example, if the folder that you want to define is $/teamproject/MyFolder/Component1, the GetChangesetForFolder property value is MyFolder/Component1.
For more information about MSBuild PropertyGroups, see.
Add the CoreLabel target and Label task overrides directly after the PropertyGroup definition.
</ItemGroup> <PropertyGroup> <GetChangesetForFolder>Component1</GetChangesetForFolder> </PropertyGroup> <Target Name="CoreLabel" Condition=" '$(IsDesktopBuild)'!='true' " DependsOnTargets="$(CoreLabelDependsOn)" > <!-- Label all the latest non deleted files in workspace --> <Label Condition=" '$(SkipLabel)'!='true' " Workspace="$(WorkspaceName)" Name="$(BuildNumber)@$/$(TeamProject)/$(GetChangesetForFolder)" Version="W$(WorkspaceName)" Files="$/$(TeamProject)/$(GetChangesetForFolder)" Recursive="$(RecursiveLabel)" /> </Target> </project>
Note the changes in Name and Files properties. These properties now contain the explicit scope to the Component1 folder.
Click File, click Save to save your changes, and then close TFSBuild.proj.
Check TFSBuild.proj back into source control. For more information, see.
After you have modified the TFSBuild.proj file and saved the changes in Team Foundation source control, run the build type. For more information, see.
Only the labeled files are built.
Only the changesets specified by the labeled items, and the work items associated with these changesets, are associated with the build.