Build: Visual Studio Build

Last Update: 3/17/2017

Team Services | TFS 2017 | TFS 2015 | Previous versions: XAML Build, Release

Build with MSBuild and set the Visual Studio version property

Demands

msbuild, visualstudio

Team Services and Team Foundation Server 2017: If your team uses Visual Studio 2017 and you want to use our hosted agents, make sure you select as your default queue the Hosted VS2017. See Hosted agents.

Arguments

Argument Description
Solution

If you want to build a single solution, click the ... button and select the solution.

If you want to build multiple solutions, specify search criteria. You can use a single-folder wildcard (*) and recursive wildcards (**). For example, **\*.sln searches for all .sln files in all subdirectories.

Make the sure the solutions you specify are downloaded by this build definition. On the Repository tab:

  • If you use TFVC, make sure that the solution is a child of one of the mappings on the Repository tab.
  • If you use Git, make sure that the project or solution is in your Git repo, in a branch that you're building.

Tips:

  • You can also build MSBuild project (.*proj) files.
  • If you are building a customized MSBuild project file, we recommend you use the MSBuild step instead of the Visual Studio Build step.
MSBuild Arguments You can pass additional arguments to MSBuild. For syntax, see MSBuild Command-Line Reference.
Platform

Specify the platform you want to build such as Win32, x86, x64 or any cpu.

Tips:

  • If you are targeting an MSBuild project (.*proj) file instead of a solution, specify AnyCPU (no whitespace).
  • Declare a build variable such as BuildPlatform on the Variables tab (selecting Allow at Queue Time) and reference it here as $(BuildPlatform). This way you can modify the platform when you queue the build and enable building multiple configurations.
Configuration

Specify the configuration you want to build such as debug or release.

Tip: Declare a build variable such as BuildConfiguration on the Variables tab (selecting Allow at Queue Time) and reference it here as $(BuildConfiguration). This way you can modify the platform when you queue the build and enable building multiple configurations.

Clean

Set to False if you want to make this an incremental build. This setting might reduce your build time, especially if your codebase is large. This option has no practical effect unless you also set Clean repository to False.

Set to True if you want to rebuild all the code in the code projects. This is equivalent to the MSBuild /target:clean argument.

Restore NuGet Packages (Important) This option is deprecated. Make sure to clear this checkbox and instead use the NuGet Installer build step.
Visual Studio Version

For some kinds of solutions, to avoid problems, you must make sure this value matches the version of Visual Studio used to create your solution.

The value you select here adds /p:VisualStudioVersion={numeric_visual_studio_version} argument to the MSBuild command run by the build. For example, if you select Visual Studio 2015, /p:VisualStudioVersion=14.0 is added to the MSBuild command.

Team Services and Team Foundation Server 2017: If you select Visual Studio 2017 or Latest and you want to use our hosted agents, make sure you select as your default queue the Hosted VS2017. See Hosted agents.

Advanced
MSBuild Architecture

Select either MSBuild x86 or MSBuild x64.

Tip: Because Visual Studio runs as a 32-bit application, you could experience problems when your build is processed by a build agent that is running the 64-bit version of Team Foundation Build Service. By selecting MSBuild x86, you might resolve these kinds of problems.

Record Project Details Select this checkbox if you want details about how much time was needed to build each project. You can see these details when you select this build step in a completed build.
Control options

Q&A

Should I use the Visual Studio Build step or the MSBuild step?

If you are building a solution, in most cases you should use the Visual Studio Build step. This step automatically:

  • Sets the /p:VisualStudioVersion property for you. This forces MSBuild to use a particular set of targets that increase the likelihood of a successful build.

  • Specifies the MSBuild version argument.

In some cases you might need to use the MSBuild step. For example, you should use it if you are building code projects apart from a solution.

Where can I learn more about MSBuild?

MSBuild step

MSBuild reference

MSBuild command-line reference

How do I build multiple configurations for multiple platforms?

  1. On the Variables tab, make sure you've got variables defined for your configurations and platforms. To specify multiple values, separate them with commas.

    For example, for a .NET app you could specify:

    Name Value
    BuildConfiguration debug, release
    BuildPlatform any cpu

    For example, for a C++ app you could specify:

    Name Value
    BuildConfiguration debug, release
    BuildPlatform x86, x64
  2. On the Options tab select MultiConfiguration and specify the Multipliers, separated by commas. For example: BuildConfiguration, BuildPlatform

    Select Parallel if you want to distribute the jobs (one for each combination of values) to multiple agents in parallel if they are available.

  3. On the Build tab, select this step and specify the Platform and Configuration arguments. For example:

    • Platform: $(BuildPlatform)
    • Configuration: $(BuildConfiguration)

Can I build TFSBuild.proj files?

You cannot build TFSBuild.proj files. These kinds of files are generated by TFS 2005 and 2008. These files contain tasks and targets are supported only using XAML builds.

Do I need an agent?

You need at least one agent to run your build or release. Get an agent.

I can't select a default agent queue and I can't queue my build or release. How do I fix this?

See queues.

I use Team Foundation Server on-premises and I don't see some of these features. Why not?

Some of these features are available only on Visual Studio Team Services and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.