-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revamp build script with corebuild, simplify packaging and versioning
- Loading branch information
Showing
12 changed files
with
325 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.0.100-pre | ||
3.0.0-alpha |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,126 @@ | ||
:: Optional batch file to quickly build with some defaults. | ||
:: Alternatively, this batch file can be invoked passing msbuild parameters, like: build.cmd "/v:detailed" "/t:Rebuild" | ||
@echo off | ||
setlocal enabledelayedexpansion | ||
|
||
@ECHO OFF | ||
:: Perf/usability tweaks for MSBuild | ||
set MSBUILDLOGASYNC=1 | ||
set MSBUILDLOGTASKINPUTS=1 | ||
set MSBUILDDISABLENODEREUSE=1 | ||
|
||
:: Ensure MSBuild can be located. Allows for a better error message below. | ||
where msbuild > %TEMP%\msbuild.txt | ||
set /p msb=<%TEMP%\msbuild.txt | ||
set BatchFile=%0 | ||
set Root=%~dp0 | ||
set NodeReuse=true | ||
set MultiProcessor=/m | ||
set BuildConfiguration= | ||
set MSBuildTarget= | ||
set MSBuildAdditionalArguments= | ||
|
||
IF "%msb%"=="" ( | ||
echo Please run %~n0 from a Visual Studio Developer Command Prompt. | ||
exit /b -1 | ||
:ParseArguments | ||
if "%1" == "" goto :DoneParsing | ||
if /I "%1" == "/?" call :Usage && exit /b 1 | ||
if /I "%1" == "/debug" set BuildConfiguration=Debug&&shift&& goto :ParseArguments | ||
if /I "%1" == "/release" set BuildConfiguration=Release&&shift&& goto :ParseArguments | ||
if /I "%1" == "/build" set MSBuildTarget=/t:Build&&shift&& goto :ParseArguments | ||
if /I "%1" == "/clean" set MSBuildTarget=/t:Clean&&shift&& goto :ParseArguments | ||
if /I "%1" == "/rebuild" set MSBuildTarget=/t:Rebuild&&shift&& goto :ParseArguments | ||
if /I "%1" == "/restore" set MSBuildTarget=/t:Restore&&shift&& goto :ParseArguments | ||
if /I "%1" == "/update" set MSBuildTarget=/t:Update&&shift&& goto :ParseArguments | ||
if /I "%1" == "/test" set MSBuildTarget=/t:Test&&shift&& goto :ParseArguments | ||
if /I "%1" == "/no-node-reuse" set NodeReuse=false&&shift&& goto :ParseArguments | ||
if /I "%1" == "/no-multi-proc" set MultiProcessor=&&shift&& goto :ParseArguments | ||
set MSBuildAdditionalArguments=%MSBuildAdditionalArguments% %1&&shift&& goto :ParseArguments | ||
:DoneParsing | ||
|
||
:: Detect if MSBuild is in the path | ||
for /f "delims=" %%i in ('where msbuild') do set "MSBuildPath=%%i" & goto :MSBuildPathDone | ||
:MSBuildPathDone | ||
|
||
if not exist "%MSBuildPath%" ( | ||
call :PrintColor Red "To build this repository, MSBuild.exe must be in the PATH." | ||
echo MSBuild is included with Visual Studio 2017 or later. | ||
echo. | ||
echo If Visual Studio is not installed, visit this page to download: | ||
echo. | ||
echo https://www.visualstudio.com/vs/ | ||
echo. | ||
exit /b 1 | ||
) | ||
|
||
:: Detect MSBuild version >= 15 | ||
for /f "delims=" %%i in ('msbuild -nologo -version') do set MSBuildFullVersion=%%i | ||
for /f "delims=. tokens=1" %%a in ("%MSBuildFullVersion%") do ( | ||
set MSBuildMajorVersion=%%a | ||
) | ||
|
||
if %MSBuildMajorVersion% LSS 15 ( | ||
call :PrintColor Red "To build this repository, the MSBuild.exe in the PATH needs to be 15.0 or higher." | ||
echo MSBuild 15.0 is included with Visual Studio 2017 or later. | ||
echo. | ||
echo If Visual Studio is not installed, visit this page to download: | ||
echo. | ||
echo https://www.visualstudio.com/vs/ | ||
echo. | ||
echo Located MSBuild in the PATH was "%MSBuildPath%". | ||
exit /b 1 | ||
) | ||
|
||
:: Ensure developer command prompt variables are set | ||
if "%VisualStudioVersion%" == "" ( | ||
for /f "delims=" %%i in ('msbuild -nologo %Root%corebuild\corebuild.targets /t:_GetVsInstallRoot /v:minimal') do set "VsInstallRoot=%%i" & goto :VsInstallRootDone | ||
:VsInstallRootDone | ||
for /f "tokens=* delims= " %%i in ("%VsInstallRoot%") do set "VsInstallRoot=%%i" | ||
set "DeveloperCommandPrompt=%VsInstallRoot%\Common7\Tools\VsDevCmd.bat" | ||
if not exist "%DeveloperCommandPrompt%" ( | ||
call :PrintColor Red "Failed to locate 'Common7\Tools\VsDevCmd.bat' under the reported Visual Studio installation root '%VsInstallRoot%'." | ||
echo. | ||
echo If Visual Studio is not installed, visit this page to download: | ||
echo. | ||
echo https://www.visualstudio.com/vs/ | ||
echo. | ||
exit /b 1 | ||
) | ||
call "%DeveloperCommandPrompt%" || goto :BuildFailed | ||
) | ||
|
||
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION | ||
PUSHD "%~dp0" >NUL | ||
if not "%MSBuildTarget%" == "" set MSBuildTargetName=%MSBuildTarget:~3% | ||
|
||
@echo on | ||
msbuild "%Root%build.proj" /nologo /nr:%NodeReuse% %MultiProcessor% %MSBuildTarget% /p:target=%MSBuildTargetName% /p:Configuration=%BuildConfiguration% %MSBuildAdditionalArguments% | ||
@echo off | ||
if ERRORLEVEL 1 ( | ||
echo. | ||
call :PrintColor Red "Build failed, for full log see msbuild.log." | ||
exit /b 1 | ||
) | ||
|
||
IF EXIST .nuget\nuget.exe goto restore | ||
IF NOT EXIST .nuget md .nuget | ||
echo Downloading latest version of NuGet.exe... | ||
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe' -OutFile .nuget/nuget.exe" | ||
echo. | ||
call :PrintColor Cyan "Build completed successfully, for full log see msbuild.log" | ||
exit /b 0 | ||
|
||
:restore | ||
:: Build script packages have no version in the path, so we install them to .nuget\packages to avoid conflicts with | ||
:: solution/project packages. | ||
IF NOT EXIST packages.config goto run | ||
.nuget\nuget.exe install packages.config -OutputDirectory .nuget\packages -ExcludeVersion | ||
:Usage | ||
echo Usage: %BatchFile% [/build^|/clean^|/rebuild^|/restore^|/update^|/test^] [/debug^|/release] [/no-node-reuse] [/no-multi-proc] [OPTIONS] | ||
echo. | ||
echo Build targets: | ||
echo /build Builds the project | ||
echo /clean Cleans a previous build | ||
echo /rebuild Cleans, then builds | ||
echo /restore Only restore NuGet packages | ||
echo /update Updates corebuild targets and dependencies | ||
echo /test Runs tests | ||
echo. | ||
echo Build options: | ||
echo /debug Perform debug build (/p:Configuration=Debug) | ||
echo /release Perform release build (/p:Configuration=Release) | ||
echo /no-node-reuse Prevents MSBuild from reusing existing MSBuild instances, | ||
echo useful for avoiding unexpected behavior on build machines ('/nr:false' switch) | ||
echo /no-multi-proc No multi-proc build, useful for diagnosing build logs (no '/m' switch) | ||
echo /noautoresponse Do not process the msbuild.rsp response file options | ||
echo | ||
echo [OPTIONS] Arbitrary MSBuild switches can also be passed in. | ||
goto :eof | ||
|
||
:run | ||
"%msb%" build.proj /v:minimal %1 %2 %3 %4 %5 %6 %7 %8 %9 | ||
:BuildFailed | ||
call :PrintColor Red "Build failed with ERRORLEVEL %ERRORLEVEL%" | ||
exit /b 1 | ||
|
||
POPD >NUL | ||
ENDLOCAL | ||
ECHO ON | ||
:PrintColor | ||
"%Windir%\System32\WindowsPowerShell\v1.0\Powershell.exe" -noprofile write-host -foregroundcolor %1 "'%2'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.