@if not "%verboseBuild%"=="y" echo off rem Shave and a Haircut rem (c) 2019 Epic Games rem US Patent 6720962 rem rem Build a Visual Studio project rem set result=0 setlocal if a%5b==ab ( echo Usage: vcbuild directory project config vsVersion solutionBaseName [bits] goto error ) set builddir=%1 set project=%2 set config=%3 set vsVersion=%4 set solution=%5 set timeStr=%TIME: =% set timeStr=%timeStr::=_% set timeStr=%timeStr:.=_% set logfile=%TEMP%\vcbuild_%timeStr%_%RANDOM%.log set platform=x64 rem For Visual Studio 7.* we used the normal solution and project file names, rem but from VS8 onward the solution and project files have Visual Studio major rem version number before the extension. E.g. "shaveHaircut-vs8.sln". rem Since the paths may contain parentheses, we cannot use the new style of rem 'if' statements here. if /i "%vsVersion%"=="vs10" goto useVS10 if /i "%vsVersion%"=="vs11" goto useVS11 if /i "%vsVersion%"=="vs14" goto useVS14 if /i "%vsVersion%"=="vs15" goto useVS15 if /i not "%vsVersion%"=="vs7" goto notVS7 set solution=%solution%.sln set project=%project%.vcproj set vsDotVersion=7.1 set vsPublicVersion=2003 set vsToolsVar=VS71COMNTOOLS set vsToolsPath=%VS71COMNTOOLS% goto doneVSVersion :notVS7 set solution=%solution%-%vsVersion%.sln set project=%project%-%vsVersion%.vcproj set vsDotVersion=8.0 set vsPublicVersion=2005 set vsToolsVar=VS80COMNTOOLS set vsToolsPath=%VS80COMNTOOLS% goto doneVSVersion :useVS10 set solution=%solution%-%vsVersion%.sln set project=%project%-%vsVersion%.vcxproj set vsDotVersion=10.0 set vsPublicVersion=2010 set vsToolsVar=VS100COMNTOOLS set vsToolsPath=%VS100COMNTOOLS% goto doneVSVersion :useVS11 set solution=%solution%-%vsVersion%.sln set project=%project%-%vsVersion%.vcxproj set vsDotVersion=11.0 set vsPublicVersion=2012 set vsToolsVar=VS110COMNTOOLS set vsToolsPath=%VS110COMNTOOLS% goto doneVSVersion :useVS14 set solution=%solution%-%vsVersion%.sln set project=%project%-%vsVersion%.vcxproj set vsDotVersion=14.0 set vsPublicVersion=2015 set vsToolsVar=VS140COMNTOOLS set vsToolsPath=%VS140COMNTOOLS% goto doneVSVersion :useVS15 set solution=%solution%-%vsVersion%.sln set project=%project%-%vsVersion%.vcxproj set vsDotVersion=15.0 set vsPublicVersion=2017 set vsToolsVar=VS150COMNTOOLS set vsToolsPath=%VS150COMNTOOLS% goto doneVSVersion :doneVSVersion if not exist "%solution%" ( echo vcbuild: Could not find solution file '%solution%'. echo vcbuild: Note that you must be in the same directory as the solution file goto error ) set vsPath=%vsToolsPath%\..\IDE\devenv.exe if exist "%vsPath%" goto foundIt set vsPath=c:\Program Files (x86)\Microsoft Visual Studio %vsDotVersion%\Common7\Tools\..\IDE\devenv.exe if exist "%vsPath%" goto foundIt set vsPath=c:\Program Files (x86)\Microsoft Visual Studio\%vsPublicVersion%\Professional\Common7\Tools\..\IDE\devenv.exe if exist "%vsPath%" goto foundIt echo vcbuild: Could not find %vsPath%. If you have installed Visual Studio echo vcbuild: %vsDotVersion% in a non-standard location, please set the echo vcbuild: %vsToolsVar% variable to point to its Tools folder. goto error :foundIt rem Remove the .exe from the devenv command so that the .com version will rem be used, if available. rem set vsPath=%vsPath:.exe=% rem rem Visual Studio has problems with .\dir notation. It's fine with rem dir1\dir2 it just seems to have trouble with using '.' for the current rem directory. So we only add the path to the project file if the build dir rem is not the current directory. rem if not "%builddir%"=="." set project=%builddir%\%project% @echo on "%vsPath%" %solution% /rebuild "%config%" /project %project% /projectconfig "%config%|%platform%" >%logfile% 2>&1 @set errcode=%errorlevel% @if not "%verboseBuild%"=="y" echo off rem If there was an error, display the build log. if not %errcode%==0 type %logfile% rem For some reason Visual Studio 2017 keeps the log file open after its command rem has returned, which causes the deletion below to fail. rem if %vsPublicVersion% LSS 2017 ( if exist %logfile% del %logfile% ) if not %errcode%==0 goto error endlocal set result=0 goto done :error endlocal set result=1 :done