What parameters does Visual Studio pass to MSBuild?

Visual StudioMsbuild

Visual Studio Problem Overview


When Visual Studio runs a build, it runs MSBuild to do the majority of the work. If you pass the .sln file to MSBuild, with appropriate Configuration and Platform properties, it will build your solution similarly to how Visual Studio would.

msbuild mysolution.sln /p:Configuration=Release /p:Platform="Any CPU"

However, there are differences: sometimes a build will error through MSBuild and not through Visual Studio, or vice-versa.

What parameters does Visual Studio pass into MSBuild to influence the process? Is there some way to see the parameters it's passing as a build is is executed?

Visual Studio Solutions


Solution 1 - Visual Studio

Visual Studio does not execute MSBuild.exe, but hosts the build engine itself (by means of the Microsoft.Build.* assemblies) - at least that is the case for the default C# project system. Other languages, addins, packages, etc. might do it differently.

Actually, there was a post series on the Microsoft blogs about this, I'm trying to find them and update this answer.

UPDATE: Found it again. Look for the "MSBuild in Visual Studio" posts here.

Concerning your original question, this page might help you further. Also you could go to "Tools", "Options", "Projects and Solutions", "Build and Run" and increase the MSBuild output verbosity. With "Diagnostic" you should basically see every property that is set upon starting the build.

Solution 2 - Visual Studio

First off, you can run msbuild with the /v:diag argument to get diagnostic-level logging. This can really help in figuring out why a build is failing.

Otherwise, yes, if you use Process Monitor, you can monitor for process start events where you can see the specific command-line sent to the process.

Specifically:

  • Run Process Monitor

  • Filter » Filter...

  • Operation is Process Create » Add

  • Operation is Process Start » Add

  • OK

  • Run your build through VS and through command-line msbuild

  • See the command-line arguments in the Detail column

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPaul TurnerView Question on Stackoverflow
Solution 1 - Visual StudioChristian.KView Answer on Stackoverflow
Solution 2 - Visual StudioChris SchmichView Answer on Stackoverflow