Differences between Visual Studio Build step and MSBuild Build step

15,940

Solution 1

They are almost the same just as Daniel mentioned. The main difference is just as what you have found: Visual Studio Build step add Visual Studio Version to the build.

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.

Solution 2

Very little. The two tasks are open-source, and they both seem to do more or less the same stuff.

https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/msbuild?view=vsts

https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/visual-studio-build?view=vsts

Solution 3

I see that this question is about the two Build Tasks.

But since Google will prominently show this question when people search for the difference between MSBuild and VS Build (not the Buildpipeline Tasks), I wanna add this quote from Microsoft:

Visual Studio builds vs. MSBuild.exe builds

There are some significant differences between when projects build in Visual Studio vs. when you invoke MSBuild directly, either through the MSBuild executable, or when you use the MSBuild object model to start a build. Visual Studio manages the project build order for Visual Studio builds; it only calls MSBuild at the individual project level, and when it does, a couple of Boolean properties (BuildingInsideVisualStudio, BuildProjectReferences) are set that significantly affect what MSBuild does. Inside each project, execution occurs the same as when invoked through MSBuild, but the difference arises with referenced projects. In MSBuild, when referenced projects are required, a build actually occurs; that is, it runs tasks and tools, and generates the output. When a Visual Studio build finds a referenced project, MSBuild only returns the expected outputs from the referenced project; it lets Visual Studio control the building of those other projects. Visual Studio determines the build order and calls into MSBuild separately (as needed), all completely under Visual Studio's control.

Another difference arises when MSBuild is invoked with a solution file, MSBuild parses the solution file, creates a standard XML input file, evaluates it, and executes it as a project. The solution build is executed before any project. When building from Visual Studio, none of this happens; MSBuild never sees the solution file. As a consequence, solution build customization (using before.SolutionName.sln.targets and after.SolutionName.sln.targets) only applies to MSBuild.exe or object model driven, not Visual Studio builds.

Source: docs.microsoft.com

Share:
15,940
Fabito
Author by

Fabito

Updated on June 15, 2022

Comments

  • Fabito
    Fabito almost 2 years

    I'm creating some build definitions and the only difference I see between the Visual Studio Build Step and MSBuild Build Step is that the VS Build Step adds the visual studio version to the build.

    Somebody can explain maybe more differences?