Share via

How to: Build Team Projects on a Desktop

Team Foundation Build provides a desktop build feature for building solutions and running tests on local binaries before checking the changes into the public Team Foundation version control server. Desktop builds behave differently from public builds in the following ways:

  • The desktop builds perform only the compilation and tests.

  • They do not perform other public build steps such as getting sources from version control, updating work items, labeling sources, creating new work items, and copying to drop locations

  • The default MSBuild logger logs the results because the Team Foundation Build logger is not enabled for desktop builds.

  • The desktop builds do not store build data in the database.

  • They do not generate any status reports. Build output is written to console. You can learn more details by enabling the Verbosity option when running the MSBuild command. For more information, see MSBuild Command Line Reference.

For information about how to queue builds, see How to: Queue or Start a Build Definition.

Required Permissions

To perform this procedure, you must have the appropriate file system permissions to be able to create files on the build agent. You must also have the appropriate file system permissions to run any additional processes you specify as part of your build process. For more information, see Team Foundation Server Permissions.

To run a desktop build

  1. Synchronize the team project root directory to a directory on the local computer. For more information, see How to: Get the Source for Your Team Project.


    Team Foundation Build stores all build definition files in version control. The default directory is TeamBuildTypes under the team project root folder. You can designate a different directory when you create a build definition.

  2. Use the MSBuild command from the Visual Studio command prompt (click Start, click All Programs, click Microsoft Visual Studio 2008, click Visual Studio Tools, and then click Visual Studio 2008 Command Prompt) and use the build definition file as the argument as shown in the following syntax:

    C:\temp\Team Project1\TeamBuildTypes\Main> MSBuild TfsBuild.proj /p:SolutionRoot=..\..


    Your folder path for the build files can be different.

    If the source has already been synchronized to a directory, for example d:\temp\mysources\solution1, you can synchronize the build type file with another directory, for example: c:\temp. Use the command as was mentioned earlier except specify the location of your sources. The command syntax is:

    MSBuild TfsBuild.proj /p:SolutionRoot= d:\temp\mysources

    You can override any property using the command line with the /p switch. The only required property for desktop build is SolutionRoot.

    As an option, you can override these properties for desktop build:

    • Verbose

    • RunFxCopFlag

  3. The following commands provide additional syntax for Team Foundation Build desktop builds:

    • msbuild TfsBuild.proj

      Use this to perform an incremental build and run tests.

    • msbuild TfsBuild.proj /t:Clean

      Use this to perform a clean operation for the binaries and all intermediate obj-folders.

    • msbuild TfsBuild.proj /t:Compile

      Use this to perform an incremental compilation.

    • msbuild TfsBuild.proj /t:Test

      Use this to run only tests.

    • msbuild TfsBuild.proj /t:DesktopRebuild

      Use this to perform a clean, full compilation and run tests.

    • msbuild TfsBuild.proj /p:BinariesRoot=d:\NewBinariesRoot /p:TestResultsRoot=d:\NewTestResultsRoot

      Use this to override the output directory by overriding the BinariesRoot where product binaries get copied and the TestResultsRoot where test results get saved.

    • msbuild TfsBuild.proj /p:RunCodeAnalysis=false

      Use this to disable code analysis in a desktop build.

    • msbuild TfsBuild.proj /p:RunTest=false

      Use this to disable test runs in desktop build.

    For more information about MSBuild command-line options, see MSBuild Command Line Reference.

See Also


Overview of Logging in MSBuild

MSBuild Properties


MSBuild Command Line Reference

Other Resources

Running Builds in Team Foundation Build