Export (0) Print
Expand All
3 out of 7 rated this helpful - Rate this topic

How to: Customize the SolutionToBuild Item Group

The Team Foundation Build project file, TFSBuild.proj, can be customized by passing properties and targets to the build in the SolutionToBuild item group. You can also add or remove solutions to build in the SolutionToBuild item group. For more information about the TFSBuild.proj file, see Understanding Team Foundation Build Configuration Files.

Required Permissions

To complete these procedures, 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.

Before you can edit the TFSBuild.proj file, you need to check it out from source control.

To edit the TFSBuild.proj file

  1. On the View menu, point to Other Windows, and then click Source Control Explorer.

  2. In Source Control Explorer, expand your team project in the Folders pane, and select TeamBuildTypes.

  3. To get the latest version of TFSBuild.proj, right-click the TeamBuildType folder, and then click Get Latest Version.

    This action makes the files available to be checked out for editing.

  4. On the viewing pane, double-click the build definition name you want to modify, right-click TFSBuild.proj, and then click Check Out for Edit. On the Check Out dialog box, select None- Allow shared checkout, and then click Check Out.

    A red check-mark appears next to the TFSBuild.proj file and indicates its source control status.

  5. Double-click the TFSBuild.proj file to open it in the Visual Studio XML-editor.

Passing Properties in SolutionToBuild Item Group

Team Foundation Build includes two reserved properties that you can use to customize build definitions:

  • CustomPropertiesForClean passes custom values into every solution when Team Foundation Build calls the Clean target.

  • CustomPropertiesForBuild passes custom values into every solution when Team Foundation Build calls its default target (typically Build).

To pass properties in SolutionToBuild item group

  1. Locate the <SolutionToBuild> tag in TFSBuild.proj file.

  2. To add a custom property to the default target, type the following between the <SolutionToBuild> and </SolutionToBuild> tags. For example:

    <SolutionToBuild Include="$(SolutionRoot)\HelloWorld.sln">
      <CustomPropertiesForBuild>
        Context=TeamBuild;RootDirectory=$(SolutionDir)
      </CustomPropertiesForBuild>
    </SolutionToBuild>
    

    This XML points the build property RootDirectory to the default SolutionDir property.

    Use the same syntax to pass custom properties in the CustomPropertiesForClean property.

  3. As an option, you can also pass custom properties into individual SolutionToBuild items by specifying them in metadata.

    For example:

    <SolutionToBuild Include="$(SolutionRoot)\HelloWorld.sln">
      <Properties>
        OutDir=$(BinariesRoot)\$(Solution)\$(Platform)\$(Configuration\
      </Properties>
    </SolutionToBuild>
    

    This XML specifies the output directory for the build definition or definitions that are associated with this TFSBuild.proj file.

    NoteNote:

    Adding the CustomPropertiesForBuild and CustomPropertiesForClean tags causes XML schema validation warnings in Visual Studio. You can safely ignore those warnings.

Adding and Deleting Solutions from SolutionToBuild Item Group

You can edit the SolutionToBuild item group to add or remove solutions that will be built by the build definition or definitions that are associated with the Team Foundation Build project file, TFSBuild.proj.

To add or remove solutions to build

  1. Locate the <SolutionToBuild> tag in TFSBuild.proj file.

    If the build definition is set to build only one solution, the SolutionToBuild entry is similar to the following XML:

    <ItemGroup>
    <SolutionToBuild Include="$(BuildProjectFolderPath)\path\MySolution.sln">
      <Targets></Targets>
      <Properties></Properties>
    </SolutionToBuild>
    </ItemGroup>
    
  2. To add another solution, add another set of <SolutionToBuild></SolutionToBuild> tags after the opening <ItemGroup> and before the closing </ItemGroup> tags.

    <SolutionToBuild Include="$(BuildProjectFolderPath)\path\MySolution.sln">
      <Targets></Targets>
      <Properties></Properties>
    </SolutionToBuild>
    <SolutionToBuild Include="$(BuildProjectFolderPath)\path\MySecondSolution.sln">
      <Targets></Targets>
      <Properties></Properties>
    </SolutionToBuild>
    
  3. To remove a solution, remove the <SolutionToBuild></SolutionToBuild> tags and everything in between the tags for the solution you no longer want to build.

You can call custom targets for individual SolutionToBuild items by specifying them in metadata.

To call a custom target in SolutionToBuild item group

  1. Locate the <SolutionToBuild> tag in TFSBuild.proj file.

  2. Use the following syntax to call a target and pass properties.

    <SolutionToBuild Include="$(BuildProjectFolderPath)\path\MySolution.sln">
      <Targets>MyCustomTarget1;MyCustomTarget2</Targets>
      <Properties>Property1=Value1;PropertyTwo=Value2</Properties>
    </SolutionToBuild>
    

    This XML calls the targets MyCustomTarget1 and MyCustomTarget2 and passes in the properties Property1 and Property2.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.