Differences between Visual Studio Build step and MSBuild Build step
Asked Answered
W

4

37

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?

Winston answered 23/9, 2016 at 19:0 Comment(0)
J
30

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.

Jugendstil answered 28/9, 2016 at 3:28 Comment(4)
You also have to use the msbuild-task when Microsoft refuses to update a program that is less than 2 years old to accommodate a new visual studio versionGroceries
we had to switch to MS build because visual studio was ignoring the database references between SSDT projects.Campuzano
Is there a requirement that Visual Studio be installed for either?Morocco
Also MSBuild ignores solution configurations, e.g. it will build all projects in a solution regardless of whether "Build" is checked in VS Configuration Manager UI.Angloirish
A
10

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

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

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

A answered 23/9, 2016 at 19:54 Comment(0)
C
10

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: learn.microsoft.com

Careycarfare answered 27/5, 2021 at 12:39 Comment(0)
W
0

With regards to self hosted DevOps agents, VSBuild has a demand of VisualStudio.

MSBuild doesn't

To satisfy the demand of VisualStudio, I need to install it, and I also need to get a straight answer from MS around licencing.

I don't understand why a sqlpacakge.exe install just doesn't sort all of this out

Writeoff answered 13/6 at 5:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.