5

Does Visual Studio (specifically VS2013) use msbuild internally to build projects?

And if so, is there a way for me to determine the exact command and arguments it uses? (And by this I mean the MSBuild command, not the individual commands that MSBuild would be calling)

My goal is to successfully build a certain projects (it is a xamarin project) using msbuild, so that later I can use my Windows-based teamcity build agent to build xamarin projects.

user2320724
  • 666
  • 3
  • 10
  • 18
  • SysInternals's ProcMon would tell you. Filter on "Operation is Process Start". You won't find "msbuild" listed. See the linked question. – Tom Blodget Mar 01 '14 at 04:01
  • Specifically for xamarin, you can use this: MSBuild "/t:SignAndroidPackage" "/p:Configuration=Release" "/p:AndroidKeyStore=true" "/p:AndroidSigningKeyAlias=YourKeyAlias" "/p:AndroidSigningKeyPass=YourKeyStorePassword" "/p:AndroidSigningKeyStore=YourKeyStoreFilename" "/p:AndroidSigningStorePass=YourKeyStorePassword" "YourAppName.csproj", see here for more details: https://www.appveyor.com/blog/2016/11/22/create-signed-aligned-xamarin-apk/ – cedd Nov 27 '16 at 20:06

3 Answers3

4

"VS uses the same MSBuild object model that is documented on MSDN"

http://blogs.msdn.com/b/msbuild/archive/2006/01/06/508981.aspx

It appears that the MSBuild command line options are not specified, but rather the MSBuild APIs are called within Visual Studio. Unless you have the Visual Studio source code to reverse engineer, you cannot get an equivalent command line.

2

Visual Studio uses msbuild.exe but it is done in an unusual way. It feeds it with build commands that are not visible at all, most likely through input/output redirection. You'll need to make-do with the common wisdom of how msbuild is executed. You use a command line like this:

   msbuild.exe yadayada.sln /t:build /p:platform=AnyCpu /p:configuration=Release

Where yadayada.sln can both be a solution file if you want to build the entire solution or an individual project file. The /t argument can also be clean or rebuild. Pick the platform and configuration that are appropriate for the solution, as visible through the VS Build + Configuration Manager dialog.

Do note that build agents like TeamCity have pre-cooked scripts so you don't have to figure this out for yourself. The MSBuild doc page is here.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Are you certain? There's a Microsoft.Build reference available that can be added to projects, and the Delphi IDE uses it to build Delphi and C++Builder apps. – Ken White Feb 28 '14 at 01:20
  • Yes, I checked. Hard to do, I had to write a prebuild event that intentionally delayed the build long enough for me to check what was going on. – Hans Passant Feb 28 '14 at 01:23
  • Hmmm. Strange; RAD Studio as far back as .NET 2 uses it internally (it installs `Borland.Delphi.Targets` and `Borland.Cpp.Targets` into the GAC to define the target types for the builds). (Note: Not disputing. Just commenting on the apparent regression from what was previously done, and is blogged in the link posted by @positivesigner in that answer.) – Ken White Feb 28 '14 at 01:25
1

Look at the build output window in Visual Studio. You may need to tweak the verbosity level in Settings, but it should show you the exact commands it is running in order to build the project.

Jason
  • 86,222
  • 15
  • 131
  • 146