Share via


Configure Team Foundation Build for an Incremental Build

This topic describes how to define an incremental build using the Upgrade Template. For more information about the Upgrade Template, see Define a Build Using the Upgrade Template. You can more easily perform this procedure using the Default template. For more information, see Define a Build Using the Default Template.

An incremental build reuses the results of a previous build that is maintained by Team Foundation Build to perform an optimized build based on the changes since the last build.

After you create a build definition for incremental builds, run the first build. This creates the required workspace and gets all the source files onto the build computer.

Prerequisites

Before you complete this task, make sure you have the following in place:

  • Access to the TFSBuild.proj file of the build type that you want to customize.

    Each team build definition has an associated TFSBuild.proj file that is located in the folder $/MyTeamProject/TeamBuildTypes/MyBuildName in Team Foundation version control. MyTeamProject is the name of your team project. It is the root node of all your team project sources. MyBuildName is the name that you gave to your build definition. For more information about how to create Team Foundation Build build types, see Create a Basic Build Definition.

  • A local workspace that contains your team project files and the build files on the local computer.

    For more information, see Create a Workspace and Get Files for the First Time and Get the Source for Your Team Project.

Tip

You can also make a build run incrementally when queuing a build by including the following string in the MSBuild Arguments parameter: /p:IncrementalBuild=true. For more information, see Queue a Build.

Required Permissions

To complete 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 Team Foundation Server Permissions.

Getting a Local Copy of the TFSBuild.proj File

Before you change the TFSBuild.proj file that defines your build definition, you must get a local copy.

To get a local copy of TFSBuild.proj file

  1. On the View menu, select Other Windows, and then select Source Control Explorer.

  2. In Source Control Explorer, click Workspaces on the toolbar, and then select your workspace from the list.

  3. Open a team project folder that contains your build type, and then expand the TeamBuildTypes folder.

  4. Right-click the TFSBuild.proj file, and select Get Latest Version to copy the latest version of the file.

    For more information, see Get the Source for Your Team Project.

Setting Properties in the TFSBuild.proj File

To specify an incremental build, you must set the IncrementalBuild property in the TFSBuild.proj file.

To set properties in the TFSBuild.proj file

  • IncrementalBuild is a convenience property that sets SkipClean to true, SkipInitializeWorkspace to true, and ForceGet to false.

  • When Team Foundation Build performs a full build, it cleans the files in the intermediate build folder and sources folder in Clean target. In an incremental build this target must be skipped because these files must be intact for the next build. To achieve this, SkipClean is set to true.

  • As a part of a full build, Team Foundation Build deletes the old, and recreates a new workspace to clean and synchronize the source files. In an incremental build, this target must be skipped also. To achieve this, SkipInitializeWorkspace is set to true.

  • In the Get task, Team Foundation Build by default retrieves new source files and overwrites the existing files in the build workspace. To only retrieve the changed files, the property ForceGet is set to false.

    To set IncrementalBuild property to true, add the PropertyGroup definition to the end of the TFSBuild.proj file, before the closing </project> tag.

       <PropertyGroup>
          <IncrementalBuild>true</IncrementalBuild>
       </PropertyGroup>
    

See Also

Concepts

Customizable Team Foundation Build Targets

Submitting Changes