1

I'm working on a batch script that will build projects made with Visual Studio 2010. I need it to build four variations of the same project: 32-bit Debug, 32-bit Release, 64-bit Debug, and 64-bit Release.

So far, I think I've figured out how to build the project with it's last saved settings:

"%MSBUILD_DIR%\MSBuild.exe" !PROJECTNAME!.vcxproj /t:Build^

How can I modify this, so that it will build the four different configurations that I need?

Jim Fell
  • 13,750
  • 36
  • 127
  • 202
  • In the long run you might be better of doing this in msbuild instead of in a batch file, as msbuild was made to perform tasks just like this (i.e. cross-product between configurations and platforms and then loop over it). Might end up shorter as well, plus you'll learn some msbuild which might come in handy in the future. – stijn Oct 24 '15 at 18:59

1 Answers1

1
@echo off
setlocal

set _project=project.vcxproj

call :do_build "%_project%" Release Win32
call :do_build "%_project%" Debug   Win32
call :do_build "%_project%" Release x64
call :do_build "%_project%" Debug   x64

endlocal
exit /b 0

:do_build
setlocal
set _proj=%~1
set _conf=%~2
set _arch=%~3
set _code=0
if "%_arch%"=="Win32" (set _vc_arg=x86) else (set _vc_arg=amd64)
call "%VS100COMNTOOLS%..\..\VC\vcvarsall.bat" %_vc_arg%
msbuild /t:build /p:Configuration="%_conf%" /p:Platform=%_arch% %_proj% || set "_code=1"
endlocal & exit /b %_code%
Dmitry Sokolov
  • 3,118
  • 1
  • 30
  • 35