Visual Studio Build task
Azure Pipelines | TFS 2018 | TFS 2017 | TFS 2015
In Microsoft Team Foundation Server (TFS) 2018 and previous versions, build and release pipelines are called definitions, service connections are called service endpoints, stages are called environments, and jobs are called phases.
Use this task in a build or release pipeline to build with MSBuild and set the Visual Studio version property.
Azure Pipelines: If your team wants to use Visual Studio 2017 with the Microsoft-hosted agents, select Hosted VS2017 as your default build pool. See Microsoft-hosted agents.
# Visual Studio Build # Build with MSBuild and set the Visual Studio version property. - task: VSBuild@1 inputs: #solution: '**\*.sln' #vsVersion: 'latest' # Optional. Options: latest, 16.0, 15.0, 14.0, 12.0, 11.0 #msbuildArgs: # Optional #platform: # Optional #configuration: # Optional #clean: false # Optional #maximumCpuCount: false # Optional #restoreNugetPackages: false # Optional #msbuildArchitecture: 'x86' # Optional. Options: x86, x64 #logProjectEvents: true # Optional #createLogFile: false # Optional #logFileVerbosity: 'normal' # Optional. Options: quiet, minimal, normal, detailed, diagnostic
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 (
Make the sure the solutions you specify are downloaded by this build pipeline. On the Repository tab:
|MSBuild Arguments||You can pass additional arguments to MSBuild. For syntax, see MSBuild Command-Line Reference.|
Specify the platform you want to build such as
Specify the configuration you want to build such as
Tip: Declare a build variable such as
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
|Restore NuGet Packages||(Important) This option is deprecated. Make sure to clear this checkbox and instead use the NuGet Installer build task.|
|Visual Studio Version||
To avoid problems overall, you must make sure this value matches the version of Visual Studio used to create your solution.
The value you select here adds the
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.|
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:
/p:VisualStudioVersionproperty 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?
How do I build multiple configurations for multiple platforms?
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
On the Options tab select MultiConfiguration and specify the Multipliers, separated by commas. For example:
Select Parallel if you want to distribute the jobs (one for each combination of values) to multiple agents in parallel if they are available.
On the Build tab, select this step and specify the Platform and Configuration arguments. For example:
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 for Linux, macOS, or Windows.
I can't select a default agent pool and I can't queue my build or release. How do I fix this?
See Agent pools.
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.