VCBuild vs. C++ MSBuild on the Command Line

In Visual Studio 2010, the command line tool vcbuild.exe will be replaced by msbuild.exe. The executable change does mean switches will change, too.  To help make the migration easier, I have created this table as a quick guide to the new switches and highlight some differences between the tools.  The table below isn’t a complete table of all the switches provided in both tools.

Migrating to MSBuild requires a new project type with a different extension (vcxproj).  Visual Studio comes with two tools for converting existing projects and solutions.  When dealing with a single project, the “vcupgrade.exe <filename>.vcproj” tool provides a quick conversion.  When dealing with multiple projects in a solution, use devenv to converts the whole solutions (.sln) and all of the projects within.  Once the project or solution has been converted without errors, you can use MSBuild.

When invoked with no explicit project configuration, VCBuild used to build all Configuration and Platform matrix by default, MSBuild, in contrast, builds only the default “Debug | Win32”.

In MSBuild, any feature that is enabled by /p[roperty] switch can also be enabled by setting the environment variable with the respective name.  For an example, “set Configuration=Debug” in the command line is the same as passing “/p:Configuration=Debug” to all MSBuild execution.

[] = optional characters to help remember the switch

Build Project

VCBuild.exe <projectname.vcproj>

MSBuild.exe <projectname.vcxproj>

Build Solution

VCBuild.exe <solutionname.sln>

MSBuild.exe <solutionname.sln>

Rebuild

/rebuild

/t[arget]:rebuild

Clean

/clean

/t[arget]:clean

Use Environment variables for INCLUDE and LIB

/useenv

/p[roperty]:useenv=true

Multi-processor build *

/m#

/m:#

Platform

/platform:<platform>

/p:Platform=<platform>

Configuration

<configuration>

/p:Configuration=<configuration>

Force Link (Link will always execute)

/forcelink

/t:BuildLink

Passes

/pass0

/t:BuildGenerateSources

 

/pass1

/t:BuildCompile

 

/pass2

/t:BuildLink /p:BuildType=Build

(BuildType property enables the incremental build tracking)

* Command line build are defaulted to use a single node (/m:1).  We encourage using n nodes where n is equal to the number of cores on the machine. 

MSBuild specific switches

Single File Build (Selected File Build)

Specify the files and tool’s target name that would execute upon the files. **

/t:<toolname> /p:SelectedFiles=”<files>”

 

/t:ClCompile

/p: SelectedFiles=”StdAfx.cpp;main.cpp”

Preprocess project file

Aggregate the project file by inlining all the files that would be imported during a build.  This doesn’t actually perform a build.

/PreProcess<:file> or /pp<:file>

 

/pp:outfile.txt

File logging

Logs the build into msbuild.log. See msbuild help for more information and options.

/FileLogger or /fl

Verbosity

Silence or increase details about the build.

Quiet and would barely show

/V[erbosity]:(q[uiet], m[inimal], n[ormal], d[etailed], or diag[nostic])

Detailed Summary

Provide statistics and summary at the end of build.

/DetailedSummary or /ds

 

** At this time, I can’t provide a list of tools, but there will be a complete list of possible targets on MSDN when it is ready.

If I have missed any options that you feel are important enough to go onto this list, please comment below.  I have left out many possible switches in order to emphasis the commonly used ones.  For further references, consider these links below:

MSBuild Command Line Reference – http://msdn.microsoft.com/en-us/library/ms164311.aspx

VC++ Building on the Command Line – http://msdn.microsoft.com/en-us/library/f35ctcxw%28VS.100%29.aspx

The New VC++ Project/Build system – https://channel9.msdn.com/posts/Charles/Bogdan-Mihalcea-The-New-VC-ProjectBuild-system-MSBuild-for-C/

Felix Huang

VC Project & Build Team