forked from ubisoft/Sharpmake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CompileSharpmake.bat
51 lines (42 loc) · 1.31 KB
/
CompileSharpmake.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
@echo off
:: Batch arguments:
:: %~1: Project/Solution to build
:: %~2: Target(Normally should be Debug or Release)
:: %~3: Platform(Normally should be "Any CPU" for sln and AnyCPU for a csproj)
setlocal enabledelayedexpansion
: set batch file directory as current
pushd "%~dp0"
set VSWHERE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if not exist %VSWHERE% (
echo ERROR: Cannot determine the location of the vswhere command Common Tools folder.
goto error
)
set VSMSBUILDCMD=
for /f "usebackq delims=" %%i in (`%VSWHERE% -latest -property installationPath`) do (
if exist "%%i\Common7\Tools\VsMSBuildCmd.bat" (
set VSMSBUILDCMD="%%i\Common7\Tools\VsMSBuildCmd.bat"
)
)
if not defined VSMSBUILDCMD (
echo ERROR: Cannot determine the location of Common Tools folder.
goto error
)
echo MSBuild batch path: !VSMSBUILDCMD!
call !VSMSBUILDCMD!
if %errorlevel% NEQ 0 goto end
call :BuildSharpmake %1 %2 %3
goto end
:: Build Sharpmake using specified arguments
:BuildSharpmake
echo Compiling %~1 in "%~2|%~3"...
set MSBUILD_CMD=msbuild -t:build -restore "%~1" /nologo /verbosity:quiet /p:Configuration="%~2" /p:Platform="%~3"
echo %MSBUILD_CMD%
%MSBUILD_CMD%
if %errorlevel% NEQ 0 (
echo ERROR: Failed to compile %~1 in "%~2|%~3".
exit /b 1
)
exit /b 0
:: End of batch file
:end
popd