Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
217 lines (170 sloc) 7.55 KB
title ms.custom description ms.topic ms.prod ms.technology ms.assetid ms.manager ms.author author ms.date monikerRange
MSBuild build and release task
seodec18
MSBuild build and release task for Azure Pipelines and Team Foundation Server (TFS)
reference
devops
devops-cicd
A104BE40-2BFD-4E80-828B-F50944C12107
mijacobs
vijayma
vijayma
08/10/2016
>= tfs-2015

MSBuild task

[!INCLUDE temp]

::: moniker range="<= tfs-2018"

[!INCLUDE temp]

::: moniker-end

Use this task in a build or release pipeline to build with MSBuild.

Demands

msbuild

Azure Pipelines: If your team uses Visual Studio 2017 and you want to use the Microsoft-hosted agents, make sure you select as your default pool the Hosted VS2017. See Microsoft-hosted agents.

::: moniker range="> tfs-2018"

YAML snippet

[!INCLUDE temp]

::: moniker-end

Arguments

Argument Description
Project

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

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

Make sure the projects you specify are downloaded by this build pipeline. On the Repository tab:

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

Tip: If you are building a solution, we recommend you use the Visual Studio build task instead of the MSBuild task.

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.

See [repo options](/devops/pipelines/repos/pipeline-options-for-git#clean-the-local-repo-on-the-agent).

Restore NuGet Packages (Important) This option is deprecated. Make sure to clear this checkbox and instead use the NuGet Installer build task.
Advanced
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.
MSBuild

In some cases you might need more control over the version of MSBuild that you are running.

Control options

Open source

This task is open source on GitHub. Feedback and contributions are welcome.

Q & A

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

If you are building a solution, in most cases you should use the Visual Studio Build task. This task 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 task. For example, you should use it if you are building code projects apart from a solution.

Where can I learn more about MSBuild?

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.

[!INCLUDE temp]

::: moniker range="< azure-devops"

[!INCLUDE temp]

::: moniker-end

You can’t perform that action at this time.