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
** 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
0 comments