@echo off
setlocal

set "config=Debug"
set "platform=Any CPU"

:arg_loop
if "%~1" == "" goto args_done

if /i "%~1" == "-?" goto usage
if /i "%~1" == "-h" goto usage
if /i "%~1" == "--help" goto usage

if /i "%~1" == "-c" (
    set "config=%~2"
    shift
)

if /i "%~1" == "--config" (
    set "config=%~2"
    shift
)

if /i "%~1" == "-p" (
    set "config=%~2"
    shift
)

if /i "%~1" == "--platform" (
    set "config=%~2"
    shift
)

shift
goto arg_loop

:usage
echo Usage:
echo ./build.cmd [option]...
echo.
echo Options:
echo -c,--config [Debug^|Release]        Set the configuration to Debug or Release (default is Release)
echo -p,--platform [Any CPU^|x86^|x64^|ARM] Build binaries for a particular platform (default is Any CPU)

goto :eof

:args_done

cd "%~dp0"
msbuild /p:Configuration="%config%" /p:Platform="%platform%"

@echo off
setlocal

set "config=Debug"
set "platform=Any CPU"

:arg_loop
if "%~1" == "" goto args_done

if /i "%~1" == "-?" goto usage
if /i "%~1" == "-h" goto usage
if /i "%~1" == "--help" goto usage

if /i "%~1" == "-c" (
    set "config=%~2"
    shift
)

if /i "%~1" == "--config" (
    set "config=%~2"
    shift
)

if /i "%~1" == "-p" (
    set "config=%~2"
    shift
)

if /i "%~1" == "--platform" (
    set "config=%~2"
    shift
)

shift
goto arg_loop

:usage
echo Usage:
echo ./build.cmd [option]...
echo.
echo Options:
echo -c,--config [Debug^|Release]        Set the configuration to Debug or Release (default is Release)
echo -p,--platform [Any CPU^|x86^|x64^|ARM] Build binaries for a particular platform (default is Any CPU)

goto :eof

:args_done

cd "%~dp0"
dnu restore
msbuild /p:Configuration="%config%" /p:Platform="%platform%"

Add a dnu restore to the build script

Add a dnu restore to the build script


:: Build and optionally publish sub projects
::
:: This script will by default build release versions of the tools.
:: If publish (-p) is requested it will create standalone versions of the
:: tools in <root>/src/<project>/<buildType>/netcoreapp1.0/<platform>/Publish/.
:: These tools can be installed via the install script (install.{sh|cmd}) in
:: this directory.
@echo on

set scriptDir=%~dp0
set appInstallDir=%scriptDir%\bin
set fxInstallDir=%scriptDir%\fx
set buildType="Release"
set publish="false"
set fx="false"
set action="build"

for /f "usebackq tokens=1,2" %%a in (`dotnet --info`) do (
    if "%%a"=="RID:" set platform=%%b
)

:argLoop
if /i "%1"=="" goto :build

if /i "%1"=="-b" (
    set buildType=%2
    shift
)
if /i "%1"=="-f" (
    set fx="true"
)
if /i "%1"=="-p" (
    set publish="true"
)
if /i "%1" == "-h" (
    goto :usage
)

shift
goto :argLoop

:build

::Change to publish if requested by the user.
if %publish% == "true" (
    set action="publish"
)

::Build each project - list any new projects here - this is a kludge but
::cmd has it's challenges.
for %%p in (corediff mcgdiff) do (
    if /i %publish%=="true" (
        dotnet publish -c %buildType% -o %appInstallDir%\%%p .\src\%%p
    ) else (
        dotnet build  -c %buildType% .\src\%%p
    )
)

if /i %fx%=="true" (
    dotnet publish -c %buildType% -o %fxInstallDir% .\src\packages

    :: remove package version of mscorlib* - refer to core root version for
    :: diff testing
    del %fxInstallDir%\mscorlib*
)

::Done
exit 0

:usage
    echo.
    echo  build.cmd [-b ^<BUILD TYPE^>] [-f] [-h] [-p]
    echo.
    echo      -b ^<BUILD TYPE^> : Build type, can be Debug or Release.
    echo      -f                : Publish default framework directory in ^<script_root^>\fx.
    echo      -h                : Show this message
    echo      -p                : Publish utilites.
    echo.
    exit -1

:: Build and optionally publish sub projects
::
:: This script will by default build release versions of the tools.
:: If publish (-p) is requested it will create standalone versions of the
:: tools in <root>/src/<project>/<buildType>/netcoreapp1.0/<platform>/Publish/.
:: These tools can be installed via the install script (install.{sh|cmd}) in
:: this directory.
@echo on

set scriptDir=%~dp0
set appInstallDir=%scriptDir%\bin
set fxInstallDir=%scriptDir%\fx
set buildType="Release"
set publish="false"
set fx="false"
set action="build"

for /f "usebackq tokens=1,2" %%a in (`dotnet --info`) do (
    if "%%a"=="RID:" set platform=%%b
)

:argLoop
if /i "%1"=="" goto :build

if /i "%1"=="-b" (
    set buildType=%2
    shift
)
if /i "%1"=="-f" (
    set fx="true"
)
if /i "%1"=="-p" (
    set publish="true"
)
if /i "%1" == "-h" (
    goto :usage
)

shift
goto :argLoop

:build

::Change to publish if requested by the user.
if %publish% == "true" (
    set action="publish"
)

::Build each project - list any new projects here - this is a kludge but
::cmd has it's challenges.
for %%p in (corediff mcgdiff) do (
    if /i %publish%=="true" (
        dotnet publish -c %buildType% -o %appInstallDir%\%%p .\src\%%p
    ) else (
        dotnet build  -c %buildType% .\src\%%p
    )
)

if /i %fx%=="true" (
    dotnet publish -c %buildType% -o %fxInstallDir% .\src\packages

    :: remove package version of mscorlib* - refer to core root version for
    :: diff testing
    del %fxInstallDir%\mscorlib*
)

::Done
exit /b 0

:usage
    echo.
    echo  build.cmd [-b ^<BUILD TYPE^>] [-f] [-h] [-p]
    echo.
    echo      -b ^<BUILD TYPE^> : Build type, can be Debug or Release.
    echo      -f                : Publish default framework directory in ^<script_root^>\fx.
    echo      -h                : Show this message
    echo      -p                : Publish utilites.
    echo.
    exit /b -1

Use exit \b

Use exit \b

Error was hidden by my powershell env.


@ECHO OFF
SETLOCAL EnableExtensions EnableDelayedExpansion

ECHO Build Amqp.Net Lite
ECHO.

SET return-code=0

CALL :file-exists MSBuild exe
IF "%MSBuildPath%" == "" (
  ECHO MSBuild.exe does not exist or is not under PATH.
  ECHO This can be resolved by building from a VS developer command prompt.
  CALL :handle-error 1
  GOTO :exit
)

SET build-target=build
SET build-config=Debug
SET build-platform=Any CPU
SET build-verbosity=minimal
SET build-dotnet=true
SET build-test=true
SET build-nuget=false
SET build-version=

IF /I "%1" EQU "release" (
  set build-target=build
  set build-config=Release
  set build-dotnet=true
  set build-nuget=true
  GOTO :args-done
)

IF /I "%1" EQU "clean" (
  set build-target=clean
  GOTO :args-done
)

IF /I "%1" EQU "test" (
  set build-target=test
  GOTO :args-done
)

:args-start
IF /I "%1" EQU "" GOTO args-done

IF /I "%1" EQU "--dotnet" SET build-dotnet=true&&GOTO args-loop
IF /I "%1" EQU "--skiptest" SET build-test=false&&GOTO args-loop
IF /I "%1" EQU "--nuget" SET build-nuget=true&&GOTO args-loop
IF /I "%1" EQU "--config" GOTO :args-config
IF /I "%1" EQU "--platform" GOTO :args-platform
IF /I "%1" EQU "--verbosity" GOTO args-verbosity
SET return-code=1
GOTO :args-error

:args-config
  SHIFT
  SET build-config=%1
  GOTO args-loop
:args-platform
  SHIFT
  SET build-platform=%1
  GOTO args-loop
:args-verbosity
  SHIFT
  SET build-verbosity=%1
  GOTO args-loop

:args-loop
SHIFT
GOTO :args-start

:args-error
CALL :handle-error 1
GOTO :exit

:args-done

ECHO Build target: %build-target%
ECHO Build configuration: %build-config%
ECHO Build platform: %build-platform%
ECHO Build dotnet: %build-dotnet%
ECHO Build run tests: %build-test%
ECHO Build NuGet package: %build-nuget%
ECHO.

IF /I "%build-config%" EQU "" GOTO :args-error
IF /I "%build-platform%" EQU "" GOTO :args-error
IF /I "%build-verbosity%" EQU "" GOTO :args-error

IF /I "%build-dotnet%" EQU "false" GOTO :build-start
CALL :file-exists dotnet exe
IF "%dotnetPath%" == "" (
  ECHO .Net Core SDK is not installed. If you unzipped the package, make sure the location is in PATH.
  GOTO :exit
)

:build-start
IF /I "%build-target%" == "clean" GOTO :build-clean
IF /I "%build-target%" == "build" GOTO :build-target
IF /I "%build-target%" == "test" GOTO :build-done
GOTO :args-error

TASKKILL /F /IM TestAmqpBroker.exe >nul 2>&1

:build-clean
CALL :run-build Clean
SET return-code=%ERRORLEVEL%
GOTO :exit

:build-target
FOR /F "tokens=1-3* delims=() " %%A in (.\src\Properties\Version.cs) do (
  IF "%%B" == "AssemblyInformationalVersion" SET build-version=%%C
)
IF "%build-version%" == "" (
  ECHO Cannot find version from Version.cs.
  SET return-code=2
  GOTO :exit
)

echo Build version %build-version%
CALL :run-build Rebuild
IF %ERRORLEVEL% NEQ 0 (
  SET return-code=%ERRORLEVEL%
  GOTO :exit
)

:build-done

IF /I "%build-test%" EQU "false" GOTO :nuget-package

CALL :file-exists MSTest exe
IF "%MSTestPath%" == "" (
  ECHO MSTest.exe does not exist or is not under PATH. Will not run tests.
  GOTO :exit
)

TASKLIST /NH /FI "IMAGENAME eq TestAmqpBroker.exe" | FINDSTR TestAmqpBroker.exe 1>nul 2>nul
IF %ERRORLEVEL% EQU 0 (
  ECHO TestAmqpBroker is already running.
  GOTO :run-test
)

SET TestBrokerPath=.\bin\%build-config%\TestAmqpBroker\TestAmqpBroker.exe
ECHO Starting the test AMQP broker
ECHO %TestBrokerPath% amqp://localhost:5672 amqps://localhost:5671 ws://localhost:18080 /creds:guest:guest /cert:localhost
START CMD.exe /C %TestBrokerPath% amqp://localhost:5672 amqps://localhost:5671 ws://localhost:18080 /creds:guest:guest /cert:localhost
rem Delay to allow broker to start up
PING -n 1 -w 2000 1.1.1.1 >nul 2>&1

:run-test
ECHO.
ECHO Running NET tests...
"%MSTestPath%" /testcontainer:.\bin\%build-config%\Test.Amqp.Net\Test.Amqp.Net.dll
IF %ERRORLEVEL% NEQ 0 (
  SET return-code=%ERRORLEVEL%
  ECHO Test failed!
  TASKKILL /F /IM TestAmqpBroker.exe
  IF /I "%is-elevated%" == "false" ECHO WebSocket tests may be failing because the broker was started without Administrator permission
  GOTO :exit
)

ECHO.
ECHO Running NET40 tests...
"%MSTestPath%" /testcontainer:.\bin\%build-config%\Test.Amqp.Net40\Test.Amqp.Net40.dll
IF %ERRORLEVEL% NEQ 0 (
  SET return-code=%ERRORLEVEL%
  ECHO Test failed!
  TASKKILL /F /IM TestAmqpBroker.exe
  GOTO :exit
)

ECHO.
ECHO Running NET35 tests...
"%MSTestPath%" /testcontainer:.\bin\%build-config%\Test.Amqp.Net35\Test.Amqp.Net35.dll
IF %ERRORLEVEL% NEQ 0 (
  SET return-code=%ERRORLEVEL%
  ECHO Test failed!
  TASKKILL /F /IM TestAmqpBroker.exe
  GOTO :exit
)

ECHO.
ECHO Running DOTNET (.Net Core 1.0) tests...
IF /I "%build-dotnet%" EQU "false" GOTO done-test
"%dotnetPath%" run --configuration %build-config% --project dotnet\Test.Amqp -- no-broker
IF %ERRORLEVEL% NEQ 0 (
  SET return-code=%ERRORLEVEL%
  ECHO .Net Core Test failed!
  GOTO :exit
)

:done-test
TASKKILL /F /IM TestAmqpBroker.exe

:nuget-package
IF /I "%build-nuget%" EQU "false" GOTO :exit

IF /I "%build-config%" NEQ "Release" (
  ECHO Not building release. Skipping NuGet package.
  GOTO :exit
)

rem Build NuGet package
ECHO.
CALL :file-exists NuGet exe
IF "%NuGetPath%" == "" (
  ECHO NuGet.exe does not exist or is not under PATH.
  ECHO If you want to build NuGet package, install NuGet.CommandLine
  ECHO package, or download NuGet.exe and place it under .\Build\tools
  ECHO directory.
) ELSE (
  IF NOT EXIST ".\Build\Packages" MKDIR ".\Build\Packages"
  ECHO Building NuGet package with version %build-version%
  "%NuGetPath%" pack .\nuspec\AMQPNetLite.nuspec -Version %build-version% -BasePath .\ -OutputDirectory ".\Build\Packages"
  IF %ERRORLEVEL% NEQ 0 (
    SET return-code=%ERRORLEVEL%
    GOTO :exit
  )
  "%NuGetPath%" pack .\nuspec\AMQPNetMicro.nuspec -Version %build-version% -BasePath .\ -OutputDirectory ".\Build\Packages"
  IF %ERRORLEVEL% NEQ 0 (
    SET return-code=%ERRORLEVEL%
    GOTO :exit
  )
  "%NuGetPath%" pack .\nuspec\AMQPNetLite.Core.nuspec -Version %build-version% -BasePath .\ -OutputDirectory ".\Build\Packages"
  IF %ERRORLEVEL% NEQ 0 (
    SET return-code=%ERRORLEVEL%
    GOTO :exit
  )
  "%NuGetPath%" pack .\nuspec\AMQPNetLite.Serialization.nuspec -Version %build-version% -BasePath .\ -OutputDirectory ".\Build\Packages"
  IF %ERRORLEVEL% NEQ 0 (
    SET return-code=%ERRORLEVEL%
    GOTO :exit
  )
  "%NuGetPath%" pack .\nuspec\AMQPNetLite.WebSockets.nuspec -Version %build-version% -BasePath .\ -OutputDirectory ".\Build\Packages"
  IF %ERRORLEVEL% NEQ 0 (
    SET return-code=%ERRORLEVEL%
    GOTO :exit
  )
)

GOTO :exit

:exit
EXIT /b %return-code%

:usage
  ECHO build.cmd [clean^|release^|test] [options]
  ECHO   clean: clean intermediate files
  ECHO   release: a shortcut for "--config Release --nuget --dotnet"
  ECHO   test: run tests only from existing build
  ECHO options:
  ECHO  --config ^<value^>      [Debug]   build configuration (e.g. Debug, Release)
  ECHO  --platform ^<value^>    [Any CPU] build platform (e.g. Win32, x64, ...)
  ECHO  --dotnet              [true]    build dotnet
  ECHO  --verbosity ^<value^>   [minimal] build verbosity (q[uiet], m[inimal], n[ormal], d[etailed] and diag[nostic])
  ECHO  --skiptest            [false]   skip test
  ECHO  --nuget               [false]   create NuGet packet (for Release only)
  GOTO :eof

:handle-error
  CALL :usage
  SET return-code=%1
  GOTO :eof

:run-build
  ECHO Build solution amqp-vs2013.sln
  "%MSBuildPath%" amqp-vs2013.sln /t:%1 /nologo /p:Configuration=%build-config%;Platform="%build-platform%" /verbosity:%build-verbosity%
  IF %ERRORLEVEL% NEQ 0 EXIT /b %ERRORLEVEL%

  ECHO Build other versions of the micro NETMF projects
  FOR /L %%I IN (2,1,3) DO (
    "%MSBuildPath%" .\src\Amqp.Micro.NetMF.csproj /t:%1 /nologo /p:Configuration=%build-config%;Platform="%build-platform: =%";FrameworkVersionMajor=4;FrameworkVersionMinor=%%I /verbosity:%build-verbosity%
    IF !ERRORLEVEL! NEQ 0 EXIT /b !ERRORLEVEL!
  )

  IF /I "%build-dotnet%" EQU "false" EXIT /b 0
  IF /I "%1" EQU "Clean" EXIT /b 0
  ECHO Build dotnet projects
  CALL "%dotnetPath%" restore dotnet
  IF !ERRORLEVEL! NEQ 0 EXIT /b !ERRORLEVEL!
  CALL "%dotnetPath%" build dotnet/Amqp dotnet/Amqp.Serialization dotnet/Amqp.WebSockets.Client dotnet\HelloAmqp dotnet/Test.Amqp --configuration %build-config% --no-incremental
  IF !ERRORLEVEL! NEQ 0 EXIT /b !ERRORLEVEL!

  EXIT /b 0

:file-exists
  IF EXIST ".\Build\tools\%1.%2" (
    SET %1Path=.\Build\tools\%1.%2
  ) ELSE (
    FOR %%f IN (%1.%2) DO IF EXIST "%%~$PATH:f" SET %1Path=%%~$PATH:f
  )
  GOTO :eof

@ECHO OFF
SETLOCAL EnableExtensions EnableDelayedExpansion

ECHO Build Amqp.Net Lite
ECHO.

SET return-code=0

CALL :findfile MSBuild exe
IF "%MSBuildPath%" == "" (
  ECHO MSBuild.exe does not exist or is not under PATH.
  ECHO This can be resolved by building from a VS developer command prompt.
  CALL :handle-error 1
  GOTO :exit
)

SET build-target=build
SET build-config=Debug
SET build-platform=Any CPU
SET build-verbosity=minimal
SET build-dotnet=true
SET build-test=true
SET build-nuget=false
SET build-version=

IF /I "%1" EQU "release" (
  set build-target=build
  set build-config=Release
  set build-dotnet=true
  set build-nuget=true
  GOTO :args-done
)

IF /I "%1" EQU "clean" (
  set build-target=clean
  GOTO :args-done
)

IF /I "%1" EQU "test" (
  set build-target=test
  GOTO :args-done
)

:args-start
IF /I "%1" EQU "" GOTO args-done

IF /I "%1" EQU "--dotnet" SET build-dotnet=true&&GOTO args-loop
IF /I "%1" EQU "--skiptest" SET build-test=false&&GOTO args-loop
IF /I "%1" EQU "--nuget" SET build-nuget=true&&GOTO args-loop
IF /I "%1" EQU "--config" GOTO :args-config
IF /I "%1" EQU "--platform" GOTO :args-platform
IF /I "%1" EQU "--verbosity" GOTO args-verbosity
SET return-code=1
GOTO :args-error

:args-config
  SHIFT
  SET build-config=%1
  GOTO args-loop
:args-platform
  SHIFT
  SET build-platform=%1
  GOTO args-loop
:args-verbosity
  SHIFT
  SET build-verbosity=%1
  GOTO args-loop

:args-loop
SHIFT
GOTO :args-start

:args-error
CALL :handle-error 1
GOTO :exit

:args-done

ECHO Build target: %build-target%
ECHO Build configuration: %build-config%
ECHO Build platform: %build-platform%
ECHO Build dotnet: %build-dotnet%
ECHO Build run tests: %build-test%
ECHO Build NuGet package: %build-nuget%
ECHO.

IF /I "%build-config%" EQU "" GOTO :args-error
IF /I "%build-platform%" EQU "" GOTO :args-error
IF /I "%build-verbosity%" EQU "" GOTO :args-error

IF /I "%build-dotnet%" EQU "false" GOTO :build-start
CALL :findfile dotnet exe
IF "%dotnetPath%" == "" (
  ECHO .Net Core SDK is not installed. If you unzipped the package, make sure the location is in PATH.
  GOTO :exit
)

:build-start
IF /I "%build-target%" == "clean" GOTO :build-clean
IF /I "%build-target%" == "build" GOTO :build-target
IF /I "%build-target%" == "test" GOTO :build-done
GOTO :args-error

TASKKILL /F /IM TestAmqpBroker.exe >nul 2>&1

:build-clean
CALL :run-build Clean
SET return-code=%ERRORLEVEL%
GOTO :exit

:build-target
FOR /F "tokens=1-3* delims=() " %%A in (.\src\Properties\Version.cs) do (
  IF "%%B" == "AssemblyInformationalVersion" SET build-version=%%C
)
IF "%build-version%" == "" (
  ECHO Cannot find version from Version.cs.
  SET return-code=2
  GOTO :exit
)

echo Build version %build-version%
CALL :run-build Rebuild
IF %ERRORLEVEL% NEQ 0 (
  SET return-code=%ERRORLEVEL%
  GOTO :exit
)

:build-done

IF /I "%build-test%" EQU "false" GOTO :nuget-package

CALL :findfile MSTest exe
IF "%MSTestPath%" == "" (
  ECHO MSTest.exe does not exist or is not under PATH. Will not run tests.
  GOTO :exit
)

TASKLIST /NH /FI "IMAGENAME eq TestAmqpBroker.exe" | FINDSTR TestAmqpBroker.exe 1>nul 2>nul
IF %ERRORLEVEL% EQU 0 (
  ECHO TestAmqpBroker is already running.
  GOTO :run-test
)

SET TestBrokerPath=.\bin\%build-config%\TestAmqpBroker\TestAmqpBroker.exe
ECHO Starting the test AMQP broker
ECHO %TestBrokerPath% amqp://localhost:5672 amqps://localhost:5671 ws://localhost:18080 /creds:guest:guest /cert:localhost
START CMD.exe /C %TestBrokerPath% amqp://localhost:5672 amqps://localhost:5671 ws://localhost:18080 /creds:guest:guest /cert:localhost
rem Delay to allow broker to start up
PING -n 1 -w 2000 1.1.1.1 >nul 2>&1

:run-test
ECHO.
ECHO Running NET tests...
"%MSTestPath%" /testcontainer:.\bin\%build-config%\Test.Amqp.Net\Test.Amqp.Net.dll
IF %ERRORLEVEL% NEQ 0 (
  SET return-code=%ERRORLEVEL%
  ECHO Test failed!
  TASKKILL /F /IM TestAmqpBroker.exe
  IF /I "%is-elevated%" == "false" ECHO WebSocket tests may be failing because the broker was started without Administrator permission
  GOTO :exit
)

ECHO.
ECHO Running NET40 tests...
"%MSTestPath%" /testcontainer:.\bin\%build-config%\Test.Amqp.Net40\Test.Amqp.Net40.dll
IF %ERRORLEVEL% NEQ 0 (
  SET return-code=%ERRORLEVEL%
  ECHO Test failed!
  TASKKILL /F /IM TestAmqpBroker.exe
  GOTO :exit
)

ECHO.
ECHO Running NET35 tests...
"%MSTestPath%" /testcontainer:.\bin\%build-config%\Test.Amqp.Net35\Test.Amqp.Net35.dll
IF %ERRORLEVEL% NEQ 0 (
  SET return-code=%ERRORLEVEL%
  ECHO Test failed!
  TASKKILL /F /IM TestAmqpBroker.exe
  GOTO :exit
)

ECHO.
ECHO Running DOTNET (.Net Core 1.0) tests...
IF /I "%build-dotnet%" EQU "false" GOTO done-test
"%dotnetPath%" run --configuration %build-config% --project dotnet\Test.Amqp -- no-broker
IF %ERRORLEVEL% NEQ 0 (
  SET return-code=%ERRORLEVEL%
  ECHO .Net Core Test failed!
  GOTO :exit
)

:done-test
TASKKILL /F /IM TestAmqpBroker.exe

:nuget-package
IF /I "%build-nuget%" EQU "false" GOTO :exit

IF /I "%build-config%" NEQ "Release" (
  ECHO Not building release. Skipping NuGet package.
  GOTO :exit
)

rem Build NuGet package
ECHO.
CALL :findfile NuGet exe
IF "%NuGetPath%" == "" (
  ECHO NuGet.exe does not exist or is not under PATH.
  ECHO If you want to build NuGet package, install NuGet.CommandLine
  ECHO package, or download NuGet.exe and place it under .\Build\tools
  ECHO directory.
) ELSE (
  IF NOT EXIST ".\Build\Packages" MKDIR ".\Build\Packages"
  ECHO Building NuGet package with version %build-version%
  "%NuGetPath%" pack .\nuspec\AMQPNetLite.nuspec -Version %build-version% -BasePath .\ -OutputDirectory ".\Build\Packages"
  IF %ERRORLEVEL% NEQ 0 (
    SET return-code=%ERRORLEVEL%
    GOTO :exit
  )
  "%NuGetPath%" pack .\nuspec\AMQPNetMicro.nuspec -Version %build-version% -BasePath .\ -OutputDirectory ".\Build\Packages"
  IF %ERRORLEVEL% NEQ 0 (
    SET return-code=%ERRORLEVEL%
    GOTO :exit
  )
  "%NuGetPath%" pack .\nuspec\AMQPNetLite.Core.nuspec -Version %build-version% -BasePath .\ -OutputDirectory ".\Build\Packages"
  IF %ERRORLEVEL% NEQ 0 (
    SET return-code=%ERRORLEVEL%
    GOTO :exit
  )
  "%NuGetPath%" pack .\nuspec\AMQPNetLite.Serialization.nuspec -Version %build-version% -BasePath .\ -OutputDirectory ".\Build\Packages"
  IF %ERRORLEVEL% NEQ 0 (
    SET return-code=%ERRORLEVEL%
    GOTO :exit
  )
  "%NuGetPath%" pack .\nuspec\AMQPNetLite.WebSockets.nuspec -Version %build-version% -BasePath .\ -OutputDirectory ".\Build\Packages"
  IF %ERRORLEVEL% NEQ 0 (
    SET return-code=%ERRORLEVEL%
    GOTO :exit
  )
)

GOTO :exit

:exit
EXIT /b %return-code%

:usage
  ECHO build.cmd [clean^|release^|test] [options]
  ECHO   clean: clean intermediate files
  ECHO   release: a shortcut for "--config Release --nuget --dotnet"
  ECHO   test: run tests only from existing build
  ECHO options:
  ECHO  --config ^<value^>      [Debug]   build configuration (e.g. Debug, Release)
  ECHO  --platform ^<value^>    [Any CPU] build platform (e.g. Win32, x64, ...)
  ECHO  --dotnet              [true]    build dotnet
  ECHO  --verbosity ^<value^>   [minimal] build verbosity (q[uiet], m[inimal], n[ormal], d[etailed] and diag[nostic])
  ECHO  --skiptest            [false]   skip test
  ECHO  --nuget               [false]   create NuGet packet (for Release only)
  GOTO :eof

:handle-error
  CALL :usage
  SET return-code=%1
  GOTO :eof

:run-build
  ECHO Build solution amqp-vs2013.sln
  "%MSBuildPath%" amqp-vs2013.sln /t:%1 /nologo /p:Configuration=%build-config%;Platform="%build-platform%" /verbosity:%build-verbosity%
  IF %ERRORLEVEL% NEQ 0 EXIT /b %ERRORLEVEL%

  ECHO Build other versions of the micro NETMF projects
  FOR /L %%I IN (2,1,3) DO (
    "%MSBuildPath%" .\src\Amqp.Micro.NetMF.csproj /t:%1 /nologo /p:Configuration=%build-config%;Platform="%build-platform: =%";FrameworkVersionMajor=4;FrameworkVersionMinor=%%I /verbosity:%build-verbosity%
    IF !ERRORLEVEL! NEQ 0 EXIT /b !ERRORLEVEL!
  )

  IF /I "%build-dotnet%" EQU "false" EXIT /b 0
  IF /I "%1" EQU "Clean" EXIT /b 0
  ECHO Build dotnet projects
  CALL "%dotnetPath%" restore dotnet
  IF !ERRORLEVEL! NEQ 0 EXIT /b !ERRORLEVEL!
  CALL "%dotnetPath%" build dotnet/Amqp dotnet/Amqp.Serialization dotnet/Amqp.WebSockets.Client dotnet\HelloAmqp dotnet/Test.Amqp --configuration %build-config% --no-incremental
  IF !ERRORLEVEL! NEQ 0 EXIT /b !ERRORLEVEL!

  EXIT /b 0

:findfile
  IF EXIST ".\Build\tools\%1.%2" (
    SET %1Path=.\Build\tools\%1.%2
  ) ELSE (
    FOR %%f IN (%1.%2) DO IF EXIST "%%~$PATH:f" SET %1Path=%%~$PATH:f
  )
  GOTO :eof

build script rename

build script rename


REM @echo Off
set config=%1
if "%config%" == "" (
   set config=Release
)

set version=1.0.0
if not "%PackageVersion%" == "" (
   set version=%PackageVersion%
)

set nuget=
if "%nuget%" == "" (
	set nuget=nuget
)

dir

echo "========"
echo %WINDIR%

powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe','nuget.exe')"

nuget.exe restore Sigma.sln

%WINDIR%\Microsoft.NET\Framework\v4.0.30319\msbuild Sigma.sln /p:Configuration="%config%" /p:Platform=x64 /m /v:M /fl /flp:LogFile=msbuild.log;Verbosity=diag /nr:false

REM pack Sigma.Core

cd Sigma.Core
nuget.exe pack "Sigma.Core.csproj" -IncludeReferencedProjects -Prop Platform=x64 -Verbosity detailed -Prop Configuration=%config% -Version %version%

cd ..

REM pack Sigma.Core.Monitors.WPF

cd Sigma.Core.Monitors.WPF

REM update the targets file

cd build
powershell -Command "(gc Sigma.Core.Monitors.WPF.targets) -replace '~version~', '%version%' | Out-File Sigma.Core.Monitors.WPF.targets"

cd ..
nuget.exe pack "Sigma.Core.Monitors.WPF.csproj" -IncludeReferencedProjects -Prop Platform=x64 -Verbosity detailed -Prop Configuration=%config% -Version %version%

REM @echo Off
set config=%1
if "%config%" == "" (
   set config=NugetBuild
)

set version=1.0.0
if not "%PackageVersion%" == "" (
   set version=%PackageVersion%
)

set nuget=
if "%nuget%" == "" (
	set nuget=nuget
)

dir

echo "========"
echo %WINDIR%

powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe','nuget.exe')"

nuget.exe restore Sigma.sln

%WINDIR%\Microsoft.NET\Framework\v4.0.30319\msbuild Sigma.sln /p:Configuration="%config%" /p:Platform=x64 /m /v:M /fl /flp:LogFile=msbuild.log;Verbosity=diag /nr:false

REM pack Sigma.Core

cd Sigma.Core
nuget.exe pack "Sigma.Core.csproj" -IncludeReferencedProjects -Prop Platform=x64 -Verbosity detailed -Prop Configuration=%config% -Version %version%

cd ..

REM pack Sigma.Core.Monitors.WPF

cd Sigma.Core.Monitors.WPF

REM update the targets file

cd build
powershell -Command "(gc Sigma.Core.Monitors.WPF.targets) -replace '~version~', '%version%' | Out-File Sigma.Core.Monitors.WPF.targets"

cd ..
nuget.exe pack "Sigma.Core.Monitors.WPF.csproj" -IncludeReferencedProjects -Prop Platform=x64 -Verbosity detailed -Prop Configuration=%config% -Version %version%

Improve NugetBuild is now default

Improve NugetBuild is now default


add build script

add build script


@echo off

pushd %~dp0

tools\nuget\NuGet.exe update -self
tools\nuget\NuGet.exe install FAKE -ConfigFile tools\nuget\Nuget.Config -OutputDirectory packages -ExcludeVersion -Version 4.12
tools\nuget\NuGet.exe install ILRepack -ConfigFile tools\nuget\Nuget.Config -OutputDirectory packages -ExcludeVersion -Version 2.0.9

set encoding=utf-8
packages\FAKE\tools\FAKE.exe build.fsx %*

popd

@echo off

pushd %~dp0

tools\nuget\NuGet.exe update -self
tools\nuget\NuGet.exe install FAKE -ConfigFile tools\nuget\Nuget.Config -OutputDirectory packages -ExcludeVersion -Version 4.22
tools\nuget\NuGet.exe install ILRepack -ConfigFile tools\nuget\Nuget.Config -OutputDirectory packages -ExcludeVersion -Version 2.0.10

set encoding=utf-8
packages\FAKE\tools\FAKE.exe build.fsx %*

popd

Update build tools

Update build tools


@echo off
cd %~dp0

SETLOCAL
SET CACHED_NUGET=%LocalAppData%\NuGet\NuGet.exe

IF EXIST %CACHED_NUGET% goto copynuget
echo Downloading latest version of NuGet.exe...
IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://www.nuget.org/nuget.exe' -OutFile '%CACHED_NUGET%'"

:copynuget
IF EXIST .nuget\nuget.exe goto restore
md .nuget
copy %CACHED_NUGET% .nuget\nuget.exe > nul

:restore
IF EXIST packages\KoreBuild goto run
.nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre
.nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion

IF "%SKIP_KRE_INSTALL%"=="1" goto run
CALL packages\KoreBuild\build\dotnetsdk upgrade -runtime CLR -x86
CALL packages\KoreBuild\build\dotnetsdk install default -runtime CoreCLR -x86

:run
CALL packages\KoreBuild\build\dotnetsdk use default -runtime CLR -x86
packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %*

@echo off
cd %~dp0

SETLOCAL
SET CACHED_NUGET=%LocalAppData%\NuGet\NuGet.exe

IF EXIST %CACHED_NUGET% goto copynuget
echo Downloading latest version of NuGet.exe...
IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://www.nuget.org/nuget.exe' -OutFile '%CACHED_NUGET%'"

:copynuget
IF EXIST .nuget\nuget.exe goto restore
md .nuget
copy %CACHED_NUGET% .nuget\nuget.exe > nul

:restore
IF EXIST packages\KoreBuild goto run
.nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre
.nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion

IF "%SKIP_DOTNET_INSTALL%"=="1" goto run
CALL packages\KoreBuild\build\dotnetsdk upgrade -runtime CLR -x86
CALL packages\KoreBuild\build\dotnetsdk install default -runtime CoreCLR -x86

:run
CALL packages\KoreBuild\build\dotnetsdk use default -runtime CLR -x86
packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %*

Rename SKIP_KRE_INSTALL to SKIP_DOTNET_INSTALL


@ECHO off
SETLOCAL

SET REPO_FOLDER=%~dp0
CD %REPO_FOLDER%

SET BUILD_FOLDER=.build
SET KOREBUILD_FOLDER=%BUILD_FOLDER%\KoreBuild-dotnet
SET KOREBUILD_VERSION=

SET NUGET_PATH=%BUILD_FOLDER%\NuGet.exe
SET NUGET_VERSION=latest
SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe

IF NOT EXIST %BUILD_FOLDER% (
    md %BUILD_FOLDER%
)

IF NOT EXIST %NUGET_PATH% (
    IF NOT EXIST %CACHED_NUGET% (
        echo Downloading latest version of NuGet.exe...
        IF NOT EXIST %LocalAppData%\NuGet (
            md %LocalAppData%\NuGet
        )
        @powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'"
    )

    copy %CACHED_NUGET% %NUGET_PATH% > nul
)

IF NOT EXIST %KOREBUILD_FOLDER% (
    SET KOREBUILD_DOWNLOAD_ARGS=
    IF NOT "%KOREBUILD_VERSION%"=="" (
        SET KOREBUILD_DOWNLOAD_ARGS=-version %KOREBUILD_VERSION%
    )

    %BUILD_FOLDER%\nuget.exe install KoreBuild-dotnet -ExcludeVersion -o %BUILD_FOLDER% -nocache -pre %KOREBUILD_DOWNLOAD_ARGS%
)

"%KOREBUILD_FOLDER%\build\KoreBuild.cmd" %*

@ECHO off
SETLOCAL

SET REPO_FOLDER=%~dp0
CD "%REPO_FOLDER%"

SET BUILD_FOLDER=.build
SET KOREBUILD_FOLDER=%BUILD_FOLDER%\KoreBuild-dotnet
SET KOREBUILD_VERSION=

SET NUGET_PATH=%BUILD_FOLDER%\NuGet.exe
SET NUGET_VERSION=latest
SET CACHED_NUGET=%LocalAppData%\NuGet\nuget.%NUGET_VERSION%.exe

IF NOT EXIST %BUILD_FOLDER% (
    md %BUILD_FOLDER%
)

IF NOT EXIST %NUGET_PATH% (
    IF NOT EXIST %CACHED_NUGET% (
        echo Downloading latest version of NuGet.exe...
        IF NOT EXIST %LocalAppData%\NuGet (
            md %LocalAppData%\NuGet
        )
        @powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/%NUGET_VERSION%/nuget.exe' -OutFile '%CACHED_NUGET%'"
    )

    copy %CACHED_NUGET% %NUGET_PATH% > nul
)

SET KOREBUILD_DOWNLOAD_ARGS=
IF NOT "%KOREBUILD_VERSION%"=="" (
    SET KOREBUILD_DOWNLOAD_ARGS=-version %KOREBUILD_VERSION%
)
IF NOT EXIST %KOREBUILD_FOLDER% (
    %BUILD_FOLDER%\nuget.exe install KoreBuild-dotnet -ExcludeVersion -o %BUILD_FOLDER% -nocache -pre %KOREBUILD_DOWNLOAD_ARGS%
)

"%KOREBUILD_FOLDER%\build\KoreBuild.cmd" %*

Use Mono 4.0.5 - Mono beta is now 4.2.1 which doesn't work reliably with `nuget.exe` - see also aspnet/External#48


@echo off
setlocal EnableDelayedExpansion

:: Set the default arguments for build
set __BuildArch=x64
set __BuildType=Debug
set __BuildOS=Windows_NT

:: Default to VS2013
set __VSVersion=VS2013
set __VSProductVersion=120

:: Set the various build properties here so that CMake and MSBuild can pick them up
set "__ProjectDir=%~dp0"
:: remove trailing slash
if %__ProjectDir:~-1%==\ set "__ProjectDir=%__ProjectDir:~0,-1%"
set "__ProjectFilesDir=%__ProjectDir%"
set "__SourceDir=%__ProjectDir%\src"
set "__PackagesDir=%__ProjectDir%\packages"
set "__RootBinDir=%__ProjectDir%\bin"
set "__LogsDir=%__RootBinDir%\Logs"
set __MSBCleanBuildArgs=

:Arg_Loop
if "%1" == "" goto ArgsDone
if /i "%1" == "/?" goto Usage
if /i "%1" == "x64"    (set __BuildArch=x64&&shift&goto Arg_Loop)

if /i "%1" == "debug"    (set __BuildType=Debug&shift&goto Arg_Loop)
if /i "%1" == "release"   (set __BuildType=Release&shift&goto Arg_Loop)

if /i "%1" == "clean"   (set __CleanBuild=1&shift&goto Arg_Loop)

if /i "%1" == "freebsdmscorlib" (set __MscorlibOnly=1&set __BuildOS=FreeBSD&shift&goto Arg_Loop)
if /i "%1" == "linuxmscorlib" (set __MscorlibOnly=1&set __BuildOS=Linux&shift&goto Arg_Loop)
if /i "%1" == "osxmscorlib" (set __MscorlibOnly=1&set __BuildOS=OSX&shift&goto Arg_Loop)
if /i "%1" == "windowsmscorlib" (set __MscorlibOnly=1&set __BuildOS=Windows_NT&shift&goto Arg_Loop)

if /i "%1" == "vs2013" (set __VSVersion=%1&set __VSProductVersion=120&shift&goto Arg_Loop)
if /i "%1" == "vs2015" (set __VSVersion=%1&set __VSProductVersion=140&shift&goto Arg_Loop)

echo Invalid commandline argument: %1
goto Usage

:ArgsDone

echo Commencing CoreCLR Repo build
echo.

:: Set the remaining variables based upon the determined build configuration
set "__BinDir=%__RootBinDir%\Product\%__BuildOS%.%__BuildArch%.%__BuildType%"
set "__IntermediatesDir=%__RootBinDir%\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"
set "__PackagesBinDir=%__BinDir%\.nuget"
set "__ToolsDir=%__RootBinDir%\tools"
set "__TestBinDir=%__RootBinDir%\tests\%__BuildOS%.%__BuildArch%.%__BuildType%"
set "__TestIntermediatesDir=%__RootBinDir%\tests\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"

:: Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash
set "__CMakeBinDir=%__BinDir%"
set "__CMakeBinDir=%__CMakeBinDir:\=/%"

:: Configure environment if we are doing a clean build.
if not defined __CleanBuild goto MakeDirs
echo Doing a clean build
echo.

:: MSBuild projects would need a rebuild
set __MSBCleanBuildArgs=/t:rebuild

:: Cleanup the previous output for the selected configuration
if exist "%__BinDir%" rd /s /q "%__BinDir%"
if exist "%__IntermediatesDir%" rd /s /q "%__IntermediatesDir%"

if exist "%__TestBinDir%" rd /s /q "%__TestBinDir%"
if exist "%__TestIntermediatesDir%" rd /s /q "%__TestIntermediatesDir%"

if exist "%__LogsDir%" del /f /q "%__LogsDir%\*_%__BuildOS%__%__BuildArch%__%__BuildType%.*"

:MakeDirs
if not exist "%__BinDir%" md "%__BinDir%"
if not exist "%__IntermediatesDir%" md "%__IntermediatesDir%"
if not exist "%__LogsDir%" md "%__LogsDir%"

:: CMake isn't a requirement when building mscorlib only
if defined __MscorlibOnly goto CheckVS

:CheckPrereqs
:: Check prerequisites
echo Checking pre-requisites...
echo.
:: Eval the output from probe-win1.ps1
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy RemoteSigned "& ""%__SourceDir%\pal\tools\probe-win.ps1"""') do %%a

goto CheckVS

:CheckVS
:: Check presence of VS
if defined VS%__VSProductVersion%COMNTOOLS goto CheckVSExistence
echo Visual Studio 2013 Community (free) is a pre-requisite to build this repository.
echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/developer-guide.md#prerequisites
exit /b 1

:CheckVSExistence
:: Does VS 2013 or VS 2015 really exist?
if exist "!VS%__VSProductVersion%COMNTOOLS!\..\IDE\devenv.exe" goto CheckMSBuild
echo Visual Studio 2013 Community (free) is a pre-requisite to build this repository.
echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/developer-guide.md#prerequisites
exit /b 1

:CheckMSBuild
:: Note: We've disabled node reuse because it causes file locking issues.
::       The issue is that we extend the build with our own targets which
::       means that that rebuilding cannot successfully delete the task
::       assembly.
if /i "%__VSVersion%" =="vs2015" goto MSBuild14
set _msbuildexe="%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe"
if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles%\MSBuild\12.0\Bin\MSBuild.exe"
if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
goto :CheckMSBuild14
:MSBuild14
set _msbuildexe="%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
set UseRoslynCompiler=true
:CheckMSBuild14
if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles%\MSBuild\14.0\Bin\MSBuild.exe"
if not exist %_msbuildexe% echo Error: Could not find MSBuild.exe.  Please see https://github.com/dotnet/coreclr/blob/master/developer-guide.md for build instructions. && exit /b 1

:: All set to commence the build

setlocal
if defined __MscorlibOnly goto PerformMScorlibBuild

echo Commencing build of native components for %__BuildOS%.%__BuildArch%.%__BuildType%
echo.

:: Set the environment for the native build
call "!VS%__VSProductVersion%COMNTOOLS!\..\..\VC\vcvarsall.bat" x86_amd64

if exist "%VSINSTALLDIR%DIA SDK" goto GenVSSolution
echo Error: DIA SDK is missing at "%VSINSTALLDIR%DIA SDK". ^
This is due to a bug in the Visual Studio installer. It does not install DIA SDK at "%VSINSTALLDIR%" but rather ^
at VS install location of previous version. Workaround is to copy DIA SDK folder from VS install location ^
of previous version to "%VSINSTALLDIR%" and then resume build.
:: DIA SDK not included in Express editions
echo Visual Studio 2013 Express does not include the DIA SDK. ^
You need Visual Studio 2013 Community (free).
echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/developer-guide.md#prerequisites
exit /b 1

:GenVSSolution
:: Regenerate the VS solution
pushd "%__IntermediatesDir%"
call "%__SourceDir%\pal\tools\gen-buildsys-win.bat" "%__ProjectDir%" %__VSVersion%
popd

:BuildComponents
if exist "%__IntermediatesDir%\install.vcxproj" goto BuildCoreCLR
echo Failed to generate native component build project!
exit /b 1

REM Build CoreCLR
:BuildCoreCLR
set "__CoreCLRBuildLog=%__LogsDir%\CoreCLR_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
%_msbuildexe% "%__IntermediatesDir%\install.vcxproj" %__MSBCleanBuildArgs% /nologo /maxcpucount /nodeReuse:false /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% /fileloggerparameters:Verbosity=diag;LogFile="%__CoreCLRBuildLog%"
IF NOT ERRORLEVEL 1 goto PerformMScorlibBuild
echo Native component build failed. Refer !__CoreCLRBuildLog! for details.
exit /b 1

:PerformMScorlibBuild
REM endlocal to rid us of environment changes from vcvarsall.bat
endlocal

REM setlocal to prepare for vsdevcmd.bat
setlocal
set __AdditionalMSBuildArgs=

rem Explicitly set Platform causes conflicts in mscorlib project files. Clear it to allow building from VS x64 Native Tools Command Prompt
set Platform=

if defined __MscorlibOnly set __AdditionalMSBuildArgs=/p:BuildNugetPackage=false

:: Set the environment for the managed build
call "!VS%__VSProductVersion%COMNTOOLS!\VsDevCmd.bat"
echo Commencing build of mscorlib for %__BuildOS%.%__BuildArch%.%__BuildType%
echo.
set "__MScorlibBuildLog=%__LogsDir%\MScorlib_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
%_msbuildexe% "%__ProjectFilesDir%\build.proj" %__MSBCleanBuildArgs% /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%__MScorlibBuildLog%" /p:OS=%__BuildOS% %__AdditionalMSBuildArgs%
IF NOT ERRORLEVEL 1 (
  if defined __MscorlibOnly exit /b 0
  goto CrossGenMscorlib
)

echo MScorlib build failed. Refer !__MScorlibBuildLog! for details.
exit /b 1

:CrossGenMscorlib
echo Generating native image of mscorlib for %__BuildOS%.%__BuildArch%.%__BuildType%
echo.
set "__CrossGenMScorlibLog=%__LogsDir%\CrossgenMScorlib_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
%__BinDir%\crossgen.exe %__BinDir%\mscorlib.dll > "%__CrossGenMScorlibLog%" 2>&1
IF NOT ERRORLEVEL 1 (
  goto PerformTestBuild
)

echo CrossGen mscorlib failed. Refer !__CrossGenMScorlibLog! for details.
exit /b 1

:PerformTestBuild
echo.
echo Commencing build of tests for %__BuildOS%.%__BuildArch%.%__BuildType%
echo.
call tests\buildtest.cmd
IF NOT ERRORLEVEL 1 goto SuccessfulBuild
echo Test binaries build failed. Refer !__MScorlibBuildLog! for details.
exit /b 1

:SuccessfulBuild
::Build complete
echo Repo successfully built.
echo.
echo Product binaries are available at !__BinDir!
echo Test binaries are available at !__TestBinDir!
exit /b 0

:Usage
echo.
echo Usage:
echo %0 BuildArch BuildType [clean] [vsversion] where:
echo.
echo BuildArch can be: x64
echo BuildType can be: Debug, Release
echo Clean - optional argument to force a clean build.
echo VSVersion - optional argument to use VS2013 or VS2015 (default VS2013)
echo windowsmscorlib - Build mscorlib for Windows
echo linuxmscorlib - Build mscorlib for Linux
echo osxmscorlib - Build mscorlib for OS X
exit /b 1

@echo off
setlocal EnableDelayedExpansion

:: Set the default arguments for build
set __BuildArch=x64
set __BuildType=Debug
set __BuildOS=Windows_NT

:: Default to VS2013
set __VSVersion=VS2013
set __VSProductVersion=120

:: Set the various build properties here so that CMake and MSBuild can pick them up
set "__ProjectDir=%~dp0"
:: remove trailing slash
if %__ProjectDir:~-1%==\ set "__ProjectDir=%__ProjectDir:~0,-1%"
set "__ProjectFilesDir=%__ProjectDir%"
set "__SourceDir=%__ProjectDir%\src"
set "__PackagesDir=%__ProjectDir%\packages"
set "__RootBinDir=%__ProjectDir%\bin"
set "__LogsDir=%__RootBinDir%\Logs"
set __MSBCleanBuildArgs=

:Arg_Loop
if "%1" == "" goto ArgsDone
if /i "%1" == "/?" goto Usage
if /i "%1" == "x64"    (set __BuildArch=x64&&shift&goto Arg_Loop)

if /i "%1" == "debug"    (set __BuildType=Debug&shift&goto Arg_Loop)
if /i "%1" == "release"   (set __BuildType=Release&shift&goto Arg_Loop)

if /i "%1" == "clean"   (set __CleanBuild=1&shift&goto Arg_Loop)

if /i "%1" == "freebsdmscorlib" (set __MscorlibOnly=1&set __BuildOS=FreeBSD&shift&goto Arg_Loop)
if /i "%1" == "linuxmscorlib" (set __MscorlibOnly=1&set __BuildOS=Linux&shift&goto Arg_Loop)
if /i "%1" == "osxmscorlib" (set __MscorlibOnly=1&set __BuildOS=OSX&shift&goto Arg_Loop)
if /i "%1" == "windowsmscorlib" (set __MscorlibOnly=1&set __BuildOS=Windows_NT&shift&goto Arg_Loop)

if /i "%1" == "vs2013" (set __VSVersion=%1&set __VSProductVersion=120&shift&goto Arg_Loop)
if /i "%1" == "vs2015" (set __VSVersion=%1&set __VSProductVersion=140&shift&goto Arg_Loop)

echo Invalid commandline argument: %1
goto Usage

:ArgsDone

echo Commencing CoreCLR Repo build
echo.

:: Set the remaining variables based upon the determined build configuration
set "__BinDir=%__RootBinDir%\Product\%__BuildOS%.%__BuildArch%.%__BuildType%"
set "__IntermediatesDir=%__RootBinDir%\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"
set "__PackagesBinDir=%__BinDir%\.nuget"
set "__ToolsDir=%__RootBinDir%\tools"
set "__TestBinDir=%__RootBinDir%\tests\%__BuildOS%.%__BuildArch%.%__BuildType%"
set "__TestIntermediatesDir=%__RootBinDir%\tests\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"

:: Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash
set "__CMakeBinDir=%__BinDir%"
set "__CMakeBinDir=%__CMakeBinDir:\=/%"

:: Configure environment if we are doing a clean build.
if not defined __CleanBuild goto MakeDirs
echo Doing a clean build
echo.

:: MSBuild projects would need a rebuild
set __MSBCleanBuildArgs=/t:rebuild

:: Cleanup the previous output for the selected configuration
if exist "%__BinDir%" rd /s /q "%__BinDir%"
if exist "%__IntermediatesDir%" rd /s /q "%__IntermediatesDir%"

if exist "%__TestBinDir%" rd /s /q "%__TestBinDir%"
if exist "%__TestIntermediatesDir%" rd /s /q "%__TestIntermediatesDir%"

if exist "%__LogsDir%" del /f /q "%__LogsDir%\*_%__BuildOS%__%__BuildArch%__%__BuildType%.*"

:MakeDirs
if not exist "%__BinDir%" md "%__BinDir%"
if not exist "%__IntermediatesDir%" md "%__IntermediatesDir%"
if not exist "%__LogsDir%" md "%__LogsDir%"

:: CMake isn't a requirement when building mscorlib only
if defined __MscorlibOnly goto CheckVS

:CheckPrereqs
:: Check prerequisites
echo Checking pre-requisites...
echo.
:: Eval the output from probe-win1.ps1
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy RemoteSigned "& ""%__SourceDir%\pal\tools\probe-win.ps1"""') do %%a

goto CheckVS

:CheckVS
:: Check presence of VS
if defined VS%__VSProductVersion%COMNTOOLS goto CheckVSExistence
echo Visual Studio 2013 Community (free) is a pre-requisite to build this repository.
echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md#prerequisites
exit /b 1

:CheckVSExistence
:: Does VS 2013 or VS 2015 really exist?
if exist "!VS%__VSProductVersion%COMNTOOLS!\..\IDE\devenv.exe" goto CheckMSBuild
echo Visual Studio 2013 Community (free) is a pre-requisite to build this repository.
echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md#prerequisites
exit /b 1

:CheckMSBuild
:: Note: We've disabled node reuse because it causes file locking issues.
::       The issue is that we extend the build with our own targets which
::       means that that rebuilding cannot successfully delete the task
::       assembly.
if /i "%__VSVersion%" =="vs2015" goto MSBuild14
set _msbuildexe="%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe"
if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles%\MSBuild\12.0\Bin\MSBuild.exe"
if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
goto :CheckMSBuild14
:MSBuild14
set _msbuildexe="%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
set UseRoslynCompiler=true
:CheckMSBuild14
if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles%\MSBuild\14.0\Bin\MSBuild.exe"
if not exist %_msbuildexe% echo Error: Could not find MSBuild.exe.  Please see https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md for build instructions. && exit /b 1

:: All set to commence the build

setlocal
if defined __MscorlibOnly goto PerformMScorlibBuild

echo Commencing build of native components for %__BuildOS%.%__BuildArch%.%__BuildType%
echo.

:: Set the environment for the native build
call "!VS%__VSProductVersion%COMNTOOLS!\..\..\VC\vcvarsall.bat" x86_amd64

if exist "%VSINSTALLDIR%DIA SDK" goto GenVSSolution
echo Error: DIA SDK is missing at "%VSINSTALLDIR%DIA SDK". ^
This is due to a bug in the Visual Studio installer. It does not install DIA SDK at "%VSINSTALLDIR%" but rather ^
at VS install location of previous version. Workaround is to copy DIA SDK folder from VS install location ^
of previous version to "%VSINSTALLDIR%" and then resume build.
:: DIA SDK not included in Express editions
echo Visual Studio 2013 Express does not include the DIA SDK. ^
You need Visual Studio 2013 Community (free).
echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md#prerequisites
exit /b 1

:GenVSSolution
:: Regenerate the VS solution
pushd "%__IntermediatesDir%"
call "%__SourceDir%\pal\tools\gen-buildsys-win.bat" "%__ProjectDir%" %__VSVersion%
popd

:BuildComponents
if exist "%__IntermediatesDir%\install.vcxproj" goto BuildCoreCLR
echo Failed to generate native component build project!
exit /b 1

REM Build CoreCLR
:BuildCoreCLR
set "__CoreCLRBuildLog=%__LogsDir%\CoreCLR_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
%_msbuildexe% "%__IntermediatesDir%\install.vcxproj" %__MSBCleanBuildArgs% /nologo /maxcpucount /nodeReuse:false /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% /fileloggerparameters:Verbosity=diag;LogFile="%__CoreCLRBuildLog%"
IF NOT ERRORLEVEL 1 goto PerformMScorlibBuild
echo Native component build failed. Refer !__CoreCLRBuildLog! for details.
exit /b 1

:PerformMScorlibBuild
REM endlocal to rid us of environment changes from vcvarsall.bat
endlocal

REM setlocal to prepare for vsdevcmd.bat
setlocal
set __AdditionalMSBuildArgs=

rem Explicitly set Platform causes conflicts in mscorlib project files. Clear it to allow building from VS x64 Native Tools Command Prompt
set Platform=

if defined __MscorlibOnly set __AdditionalMSBuildArgs=/p:BuildNugetPackage=false

:: Set the environment for the managed build
call "!VS%__VSProductVersion%COMNTOOLS!\VsDevCmd.bat"
echo Commencing build of mscorlib for %__BuildOS%.%__BuildArch%.%__BuildType%
echo.
set "__MScorlibBuildLog=%__LogsDir%\MScorlib_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
%_msbuildexe% "%__ProjectFilesDir%\build.proj" %__MSBCleanBuildArgs% /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%__MScorlibBuildLog%" /p:OS=%__BuildOS% %__AdditionalMSBuildArgs%
IF NOT ERRORLEVEL 1 (
  if defined __MscorlibOnly exit /b 0
  goto CrossGenMscorlib
)

echo MScorlib build failed. Refer !__MScorlibBuildLog! for details.
exit /b 1

:CrossGenMscorlib
echo Generating native image of mscorlib for %__BuildOS%.%__BuildArch%.%__BuildType%
echo.
set "__CrossGenMScorlibLog=%__LogsDir%\CrossgenMScorlib_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
%__BinDir%\crossgen.exe %__BinDir%\mscorlib.dll > "%__CrossGenMScorlibLog%" 2>&1
IF NOT ERRORLEVEL 1 (
  goto PerformTestBuild
)

echo CrossGen mscorlib failed. Refer !__CrossGenMScorlibLog! for details.
exit /b 1

:PerformTestBuild
echo.
echo Commencing build of tests for %__BuildOS%.%__BuildArch%.%__BuildType%
echo.
call tests\buildtest.cmd
IF NOT ERRORLEVEL 1 goto SuccessfulBuild
echo Test binaries build failed. Refer !__MScorlibBuildLog! for details.
exit /b 1

:SuccessfulBuild
::Build complete
echo Repo successfully built.
echo.
echo Product binaries are available at !__BinDir!
echo Test binaries are available at !__TestBinDir!
exit /b 0

:Usage
echo.
echo Usage:
echo %0 BuildArch BuildType [clean] [vsversion] where:
echo.
echo BuildArch can be: x64
echo BuildType can be: Debug, Release
echo Clean - optional argument to force a clean build.
echo VSVersion - optional argument to use VS2013 or VS2015 (default VS2013)
echo windowsmscorlib - Build mscorlib for Windows
echo linuxmscorlib - Build mscorlib for Linux
echo osxmscorlib - Build mscorlib for OS X
exit /b 1

Fix broken Developer Guide documentation links


@ECHO OFF
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*"

@ECHO OFF
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE"

Return the error code from build.cmd

Return the error code from build.cmd


Return the error code from build.cmd

Return the error code from build.cmd


add start.bat

add start.bat


### application.bat - 2015 - Louis ABID ###
echo "Build : 10:00"
echo "version 1"

Add header

Add header


@echo off

for /d %%d in ("*") do (
	if exist "%%d\bin" rmdir /s /q "%%d\bin"
	if exist "%%d\obj" rmdir /s /q "%%d\obj"
)

if exist *.db del /q *.db
if exist *.log del /q *.log

if exist "packages" rmdir /s /q "packages"
if exist "TestResults" rmdir /s /q "TestResults"

if exist "BitSharp.BlockHelper\Blocks" rmdir /s /q "BitSharp.BlockHelper\Blocks"
if exist "BitSharp.IntegrationTest\bitcoinj" rmdir /s /q "BitSharp.IntegrationTest\bitcoinj"

add bitcoinj repo to clean script

add bitcoinj repo to clean script


@echo off

if exist "%~dp0vendors\clink\clink_x%PROCESSOR_ARCHITECTURE:~-2%.exe" "%~dp0vendors\clink\clink_x%PROCESSOR_ARCHITECTURE:~-2%.exe" inject --quiet --profile "%~dp0etc\clink"

if exist "%~dp0cmd.env.bat" call "%~dp0cmd.env.bat"

:: Integrate Git into prompt
if defined ConEmuBaseDir if exist "%ConEmuBaseDir%\IsConEmu.cmd" (
	call "%ConEmuBaseDir%\IsConEmu.cmd" >nul && prompt $p$s{git}$_$g$s
)

@echo off

if exist "%~dp0vendors\clink\clink_x%PROCESSOR_ARCHITECTURE:~-2%.exe" "%~dp0vendors\clink\clink_x%PROCESSOR_ARCHITECTURE:~-2%.exe" inject --quiet --profile "%~dp0etc\clink"

if exist "%~dp0cmd.env.bat" call "%~dp0cmd.env.bat"

:: Integrate Git into prompt
call "%ConEmuBaseDir%\IsConEmu.cmd" >nul && prompt $p$s{git}$_$g$s

update clink.bat startup

update clink.bat startup


@echo off
setlocal

if not defined VisualStudioVersion (
    if defined VS140COMNTOOLS (
        call "%VS140COMNTOOLS%\VsDevCmd.bat"
        goto :EnvSet
    )

    echo Error: build.cmd requires Visual Studio 2015.
    exit /b -1
)
:EnvSet

set _DeviceId=
set _Platform=
set _SdkRoot=%ProgramFiles(x86)%\Android\android-sdk
set _NdkRoot=%ProgramData%\Microsoft\AndroidNDK\android-ndk-r11c
set _LoopCount=
set _Verbose=
set _TestsToRun=

if "%~1"=="-?" goto Help
if "%~1"=="/?" goto Help

call :SetProjectRoot %~dp0..\..\

set _GlassPackageName=Microsoft.VisualStudio.Glass
set _GlassPackageVersion=1.0.0

set _GlassDir=%_ProjectRoot%%_GlassPackageName%\

:: Get Glass from NuGet
if NOT exist "%_GlassDir%glass2.exe" echo Getting Glass from NuGet.& call "%_ProjectRoot%tools\NuGet\nuget.exe" install %_GlassPackageName% -Version %_GlassPackageVersion% -ExcludeVersion -OutputDirectory %_ProjectRoot%
if NOT "%ERRORLEVEL%"=="0" echo ERROR: Failed to get Glass from NuGet.& exit /b -1

:: Ensure the project has been built
if NOT exist "%_GlassDir%Microsoft.MIDebugEngine.dll" echo The project has not been built. Building now with default settings.& call %_ProjectRoot%build.cmd
if NOT "%ERRORLEVEL%"=="0" echo ERROR: Failed to build MIEngine project.& exit /b -1

:: Copy libadb.dll to the glass directory
xcopy /Y /D "%VSINSTALLDIR%Common7\IDE\PrivateAssemblies\libadb.dll" "%_GlassDir%"
if not "%ERRORLEVEL%"=="0" echo ERROR: Unable to copy libadb.dll from Visual Studio installation.& exit /b -1

call :EnsureGlassRegisterd
if not "%ERRORLEVEL%"=="0" exit /b -1

call :EnsureLaunchOptionsGenBuilt

:ArgLoopStart
if "%~1"=="" goto ArgLoopEnd
if /i "%~1"=="/DeviceId"    goto SetDeviceId
if /i "%~1"=="/Platform"    goto SetPlatform
if /i "%~1"=="/SdkRoot"     goto SetSdkRoot
if /i "%~1"=="/NdkRoot"     goto SetNdkRoot
if /i "%~1"=="/v"           set _Verbose=1& goto NextArg
if /i "%~1"=="/Loop"        goto SetLoop
if /i "%~1"=="/Tests"       goto SetTests
echo ERROR: Unknown argument '%~1'.&exit /b -1

:NextArg
shift /1
goto ArgLoopStart

:SetDeviceId
shift /1
set _DeviceId=%~1
goto :NextArg

:SetPlatform
shift /1
set _Platform=%~1&
goto :NextArg

:SetSdkRoot
shift /1
set _SdkRoot=%~1
goto :NextArg

:SetNdkRoot
shift /1
set _NdkRoot=%~1
goto :NextArg

:SetLoop
shift /1
set _LoopCount=%~1
goto :NextArg

:SetTests
shift /1
if "%~1"=="" goto SetTestsDone
set _TestsToRun="%~1" %_TestsToRun%
goto SetTests
:SetTestsDone
goto ArgLoopEnd

:ArgLoopEnd

if NOT exist "%_SdkRoot%" echo ERROR: Android SDK does not exist at "%_SdkRoot%".& exit /b -1
if NOT exist "%_NdkRoot%" echo ERROR: Android NDK does not exist at "%_NdkRoot%".& exit /b -1

if "%_DeviceId%"=="" call :FindDeviceId
if "%_DeviceId%"=="" echo ERROR: DeviceId must be specified. Possible devices are:& "%_AdbExe%" devices &goto Help

set _GlassFlags=-f TestScript.xml -e ErrorLog.xml -s SessionLog.xml -err -nodefaultsetup -nodvt
if not "%_Verbose%"=="1" set _GlassFlags=%_GlassFlags% -q

set _GlassLog=
if NOT "%_Verbose%"=="1" set _GlassLog=^> glass.log

if "%_Verbose%"=="1" (
    echo DeviceId:    %_DeviceId%
    echo Platform:    %_Platform%
    echo SdkRoot:     "%_SdkRoot%"
    echo NdkRoot:     "%_NdkRoot%"
    echo Tests:       %_TestsToRun%
    echo Glass Flags: %_GlassFlags%
)

if "%_TestsToRun%"=="" goto RunAll
goto RunArgs

:FindDeviceId
if "%_Platform%"=="" set _Platform=x86
pushd %_SdkRoot%
for /f "tokens=1,6" %%i in ('platform-tools\adb devices -l ^| find /i "VS Emulator"') do (
    echo Run on device: %%i %%j
    set _DeviceId=%%i
    popd
    exit /b 0
)

:RunAll
    set FAILED_TESTS=

    pushd %~dp0
    for /d %%t in (*) do if exist "%%t\TestScript.xml" call :RunSingleTest "%%t"
    goto ReportResults

:RunArgs
    set FAILED_TESTS=

    pushd %~dp0
    for %%t in (%_TestsToRun%) do call :ValidateArg %%t
    if NOT "%FAILED_TESTS%"=="" exit /b -1
    for %%t in (%_TestsToRun%) do call :RunSingleTest %%t
    goto ReportResults

:ReportResults
    echo ----------------------------------------
    if NOT "%FAILED_TESTS%"=="" goto ReportFailure
    goto ReportSuccess

:ReportFailure
    echo ERROR: Failures detected 'AndroidTest.cmd /DeviceId %_DeviceId% /Platform %_Platform% /Tests %FAILED_TESTS%' to rerun.
    echo.
    exit /b -1

:ReportSuccess
    echo All tests completed succesfully.
    echo.
    exit /b 0

:ValidateArg
    if not exist "%~1" echo ERROR: Test '%~1' does not exist.& set FAILED_TESTS="%~1" %FAILED_TESTS%& exit /b 0
    if not exist "%~1\TestScript.xml" echo ERROR: Test '%~1' does not have a TestScript.xml file.& set FAILED_TESTS="%~1" %FAILED_TESTS%& exit /b 0
    exit /b 0

:RunSingleTest
    if "%_LoopCount%"=="" goto RunSingleTestOnce
    set _ContinueRunningTests=true
    FOR /L %%l IN (1,1,%_LoopCount%) DO call :RunSingleTestInLoop %*
    goto EOF

:RunSingleTestInLoop
    if NOT "%_ContinueRunningTests%"=="true" goto EOF
    call :RunSingleTestOnce %*
    if NOT "%LastTestSucceeded%"=="true" set _ContinueRunningTests=false
    goto EOF

:RunSingleTestOnce
    pushd "%~1"
    echo Running '%~1'
    set LastTestSucceeded=false

    ::Build the app
    call msbuild /p:Platform=%_Platform%;VS_NDKRoot="%_NdkRoot%";VS_SDKRoot="%_SdkRoot%";PackageDebugSymbols=true > build.log
    if NOT "%ERRORLEVEL%"=="0" echo ERROR: Failed to build %~1. See build.log for more information.& set FAILED_TESTS="%~1" "%FAILED_TESTS%"& goto RunSingleTestDone

    ::Deploy the app
    call "%_SdkRoot%\platform-tools\adb.exe" -s %_DeviceId% install -r %_Platform%\Debug\%~1.apk > adb.log
    if NOT "%ERRORLEVEL%"=="0" echo ERROR: adb failed for one reason or another.& set FAILED_TESTS="%~1" "%FAILED_TESTS%"& goto RunSingleTestDone

    ::Create temp directory
    if not exist temp mkdir temp

    ::Generate the LaunchOptions
    call %_GlassDir%LaunchOptionsGen.exe LaunchOptions.xml.template "SdkRoot=%_SdkRoot%\ " "NdkRoot=%_NdkRoot%\ " "TargetArchitecture=%_Platform%" "IntermediateDirectory=%~dp1temp\ " "AdditionalSOLibSearchPath=%~dp1%_Platform%\Debug\ " "DeviceId=%_DeviceId%"

    ::Run Glass
    call "%_GlassDir%glass2.exe" %_GlassFlags% %_GlassLog%
    if NOT "%ERRORLEVEL%"=="0" echo ERROR: Test failed. See ErrorLog.xml for more information.& set FAILED_TESTS="%~1" %FAILED_TESTS%& goto RunSingleTestDone

    set LastTestSucceeded=true

    :: remove installed package
    call "%_SdkRoot%\platform-tools\adb.exe" -s %_DeviceId% shell pm uninstall -k com.%~1  > adb.log

    :RunSingleTestDone
    popd
    exit /b 0

::These are functions called at the beginning

:EnsureGlassRegisterd
REM Check if the key exists. If not, we need to register glass.
reg query HKLM\SOFTWARE\Microsoft\glass\14.0 /v InstallDir /reg:32 1>NUL 2>NUL
if NOT "%ERRORLEVEL%"=="0" goto :RegisterGlass

REM Check if glass is currently registered at a differnt location
set CurrentGlassRegRoot=
for /f "tokens=3* skip=2" %%a in ('reg query HKLM\SOFTWARE\Microsoft\glass\14.0 /v InstallDir /reg:32') do call :SetCurrentGlassRegRoot %%a %%b %%c %%d %%e
if /i "%CurrentGlassRegRoot%"=="%_GlassDir%" goto EOF

:RegisterGlass
echo Running RegisterGlass.cmd...
call "%_GlassDir%RegisterGlass.cmd"
if NOT "%ERRORLEVEL%"=="0" echo ERROR: Unable to register glass. Ensure that this command prompt is elevated.& goto :EOF
call "%~dp0..\RegisterMIEngine.cmd"
if NOT "%ERRORLEVEL%"=="0" echo ERROR: Unable to register MIEngine.& goto :EOF
set ERRORLEVEL=0
goto EOF

:SetCurrentGlassRegRoot
REM %1 contains the glass install root. Unfortunately, if the path to the has spaces in it,
REM these will get broken up with each chunk in a different token. Lets try to put these tokens
REM back together.
set CurrentGlassRegRoot=%1
if "%2"=="%%b" goto EOF
if "%2"=="" goto EOF
if "%2"=="d" goto EOF
set CurrentGlassRegRoot=%1 %2
if "%3"=="%%c" goto EOF
if "%3"=="" goto EOF
if "%3"=="e" goto EOF
set CurrentGlassRegRoot=%1 %2 %3
if "%4"=="%%d" goto EOF
if "%4"=="" goto EOF
set CurrentGlassRegRoot=%1 %2 %3 %4
if "%5"=="%%e" goto EOF
if "%5"=="" goto EOF
set CurrentGlassRegRoot=%1 %2 %3 %4 %5
goto EOF

:EnsureLaunchOptionsGenBuilt
if not exist %_GlassDir%LaunchOptionsGen.exe echo Building LaunchOptionsGen.exe& msbuild /p:Configuration=Release;OutDir=%_GlassDir% /v:quiet %~dp0..\LaunchOptionsGen\LaunchOptionsGen.csproj
exit /b 0

:SetProjectRoot
set _ProjectRoot=%~f1
goto EOF

:Help
echo --- MIEngine Android Test Script ---
echo Usage: androidtest.cmd /DeviceId ^<id^> /Platform ^<platform^> [/SdkRoot ^<path^>] [/NdkRoot ^<path^>] [/v] [/Loop ^<num_iterations^>] [/Tests ^<test 1^> [^<test 2^> [...]]]
echo.
echo --- Examples ---
echo Run All Tests:
echo androidtest.cmd /DeviceId 169.254.138.123:5555 /Platform x86
echo.
echo Run two specific tests:
echo androidtest.cmd /DeviceId 169.254.138.123:5555 /Platform x86 /Tests Stepping Exceptions
echo.

if exist "%_SdkRoot%" "%_SdkRoot%\platform-tools\adb.exe" devices -l

:EOF

@echo off
setlocal

if not defined VisualStudioVersion (
    if defined VS140COMNTOOLS (
        call "%VS140COMNTOOLS%\VsDevCmd.bat"
        goto :EnvSet
    )

    echo Error: build.cmd requires Visual Studio 2015.
    exit /b -1
)
:EnvSet

set _DeviceId=
set _Platform=
set _SdkRoot=%ProgramFiles(x86)%\Android\android-sdk
set _NdkRoot=%ProgramData%\Microsoft\AndroidNDK\android-ndk-r11c
set _LoopCount=
set _Verbose=
set _TestsToRun=

if "%~1"=="-?" goto Help
if "%~1"=="/?" goto Help

call :SetProjectRoot %~dp0..\..\

set _GlassPackageName=Microsoft.VisualStudio.Glass
set _GlassPackageVersion=1.0.0

set _GlassDir=%_ProjectRoot%%_GlassPackageName%\

:: Get Glass from NuGet
if NOT exist "%_GlassDir%glass2.exe" echo Getting Glass from NuGet.& call "%_ProjectRoot%tools\NuGet\nuget.exe" install %_GlassPackageName% -Version %_GlassPackageVersion% -ExcludeVersion -OutputDirectory %_ProjectRoot%
if NOT "%ERRORLEVEL%"=="0" echo ERROR: Failed to get Glass from NuGet.& exit /b -1

:: Ensure the project has been built
if NOT exist "%_GlassDir%Microsoft.MIDebugEngine.dll" echo The project has not been built. Building now with default settings.& call %_ProjectRoot%build.cmd
if NOT "%ERRORLEVEL%"=="0" echo ERROR: Failed to build MIEngine project.& exit /b -1

:: Copy libadb.dll to the glass directory
xcopy /Y /D "%VSINSTALLDIR%Common7\IDE\PrivateAssemblies\libadb.dll" "%_GlassDir%"
if not "%ERRORLEVEL%"=="0" echo ERROR: Unable to copy libadb.dll from Visual Studio installation.& exit /b -1

call :EnsureGlassRegisterd
if not "%ERRORLEVEL%"=="0" exit /b -1

call :EnsureLaunchOptionsGenBuilt

:ArgLoopStart
if "%~1"=="" goto ArgLoopEnd
if /i "%~1"=="/DeviceId"    goto SetDeviceId
if /i "%~1"=="/Platform"    goto SetPlatform
if /i "%~1"=="/SdkRoot"     goto SetSdkRoot
if /i "%~1"=="/NdkRoot"     goto SetNdkRoot
if /i "%~1"=="/v"           set _Verbose=1& goto NextArg
if /i "%~1"=="/Loop"        goto SetLoop
if /i "%~1"=="/Tests"       goto SetTests
echo ERROR: Unknown argument '%~1'.&exit /b -1

:NextArg
shift /1
goto ArgLoopStart

:SetDeviceId
shift /1
set _DeviceId=%~1
goto :NextArg

:SetPlatform
shift /1
set _Platform=%~1&
goto :NextArg

:SetSdkRoot
shift /1
set _SdkRoot=%~1
goto :NextArg

:SetNdkRoot
shift /1
if "%~1" == "10" (
	set _NdkRoot=%ProgramData%\Microsoft\AndroidNDK\android-ndk-r10e
) else (
	set _NdkRoot=%~1
)
goto :NextArg

:SetLoop
shift /1
set _LoopCount=%~1
goto :NextArg

:SetTests
shift /1
if "%~1"=="" goto SetTestsDone
set _TestsToRun="%~1" %_TestsToRun%
goto SetTests
:SetTestsDone
goto ArgLoopEnd

:ArgLoopEnd

if NOT exist "%_SdkRoot%" echo ERROR: Android SDK does not exist at "%_SdkRoot%".& exit /b -1
if NOT exist "%_NdkRoot%" echo ERROR: Android NDK does not exist at "%_NdkRoot%".& exit /b -1

if "%_DeviceId%"=="" call :FindDeviceId
if "%_DeviceId%"=="" echo ERROR: DeviceId must be specified. Possible devices are:& "%_AdbExe%" devices &goto Help

set _GlassFlags=-f TestScript.xml -e ErrorLog.xml -s SessionLog.xml -err -nodefaultsetup -nodvt
if not "%_Verbose%"=="1" set _GlassFlags=%_GlassFlags% -q

set _GlassLog=
if NOT "%_Verbose%"=="1" set _GlassLog=^> glass.log

if "%_Verbose%"=="1" (
    echo DeviceId:    %_DeviceId%
    echo Platform:    %_Platform%
    echo SdkRoot:     "%_SdkRoot%"
    echo NdkRoot:     "%_NdkRoot%"
    echo Tests:       %_TestsToRun%
    echo Glass Flags: %_GlassFlags%
)

if "%_TestsToRun%"=="" goto RunAll
goto RunArgs

:FindDeviceId
if "%_Platform%"=="" set _Platform=x86
pushd %_SdkRoot%
for /f "tokens=1,6" %%i in ('platform-tools\adb devices -l ^| find /i "VS Emulator"') do (
    echo Run on device: %%i %%j
    set _DeviceId=%%i
    popd
    exit /b 0
)
exit /b -1

:RunAll
    set FAILED_TESTS=

    pushd %~dp0
    for /d %%t in (*) do if exist "%%t\TestScript.xml" call :RunSingleTest "%%t"
    goto ReportResults

:RunArgs
    set FAILED_TESTS=

    pushd %~dp0
    for %%t in (%_TestsToRun%) do call :ValidateArg %%t
    if NOT "%FAILED_TESTS%"=="" exit /b -1
    for %%t in (%_TestsToRun%) do call :RunSingleTest %%t
    goto ReportResults

:ReportResults
    echo ----------------------------------------
    if NOT "%FAILED_TESTS%"=="" goto ReportFailure
    goto ReportSuccess

:ReportFailure
    echo ERROR: Failures detected 'AndroidTest.cmd /DeviceId %_DeviceId% /Platform %_Platform% /Tests %FAILED_TESTS%' to rerun.
    echo.
    exit /b -1

:ReportSuccess
    echo All tests completed succesfully.
    echo.
    exit /b 0

:ValidateArg
    if not exist "%~1" echo ERROR: Test '%~1' does not exist.& set FAILED_TESTS="%~1" %FAILED_TESTS%& exit /b 0
    if not exist "%~1\TestScript.xml" echo ERROR: Test '%~1' does not have a TestScript.xml file.& set FAILED_TESTS="%~1" %FAILED_TESTS%& exit /b 0
    exit /b 0

:RunSingleTest
    if "%_LoopCount%"=="" goto RunSingleTestOnce
    set _ContinueRunningTests=true
    FOR /L %%l IN (1,1,%_LoopCount%) DO call :RunSingleTestInLoop %*
    goto EOF

:RunSingleTestInLoop
    if NOT "%_ContinueRunningTests%"=="true" goto EOF
    call :RunSingleTestOnce %*
    if NOT "%LastTestSucceeded%"=="true" set _ContinueRunningTests=false
    goto EOF

:RunSingleTestOnce
    pushd "%~1"
    echo Running '%~1'
    set LastTestSucceeded=false

    ::Build the app
    call msbuild /p:Platform=%_Platform%;VS_NDKRoot="%_NdkRoot%";VS_SDKRoot="%_SdkRoot%";PackageDebugSymbols=true > build.log
    if NOT "%ERRORLEVEL%"=="0" echo ERROR: Failed to build %~1. See build.log for more information.& set FAILED_TESTS="%~1" "%FAILED_TESTS%"& goto RunSingleTestDone

    ::Deploy the app
    call "%_SdkRoot%\platform-tools\adb.exe" -s %_DeviceId% install -r %_Platform%\Debug\%~1.apk > adb.log
    if NOT "%ERRORLEVEL%"=="0" echo ERROR: adb failed for one reason or another.& set FAILED_TESTS="%~1" "%FAILED_TESTS%"& goto RunSingleTestDone

    ::Create temp directory
    if not exist temp mkdir temp

    ::Generate the LaunchOptions
    call %_GlassDir%LaunchOptionsGen.exe LaunchOptions.xml.template "SdkRoot=%_SdkRoot%\ " "NdkRoot=%_NdkRoot%\ " "TargetArchitecture=%_Platform%" "IntermediateDirectory=%~dp1temp\ " "AdditionalSOLibSearchPath=%~dp1%_Platform%\Debug\ " "DeviceId=%_DeviceId%"

    ::Run Glass
    call "%_GlassDir%glass2.exe" %_GlassFlags% %_GlassLog%
    if NOT "%ERRORLEVEL%"=="0" echo ERROR: Test failed. See ErrorLog.xml for more information.& set FAILED_TESTS="%~1" %FAILED_TESTS%& goto RunSingleTestDone

    set LastTestSucceeded=true

    :: remove installed package
    call "%_SdkRoot%\platform-tools\adb.exe" -s %_DeviceId% shell pm uninstall -k com.%~1  > adb.log

    :RunSingleTestDone
    popd
    exit /b 0

::These are functions called at the beginning

:EnsureGlassRegisterd
REM Check if the key exists. If not, we need to register glass.
reg query HKLM\SOFTWARE\Microsoft\glass\14.0 /v InstallDir /reg:32 1>NUL 2>NUL
if NOT "%ERRORLEVEL%"=="0" goto :RegisterGlass

REM Check if glass is currently registered at a differnt location
set CurrentGlassRegRoot=
for /f "tokens=3* skip=2" %%a in ('reg query HKLM\SOFTWARE\Microsoft\glass\14.0 /v InstallDir /reg:32') do call :SetCurrentGlassRegRoot %%a %%b %%c %%d %%e
if /i "%CurrentGlassRegRoot%"=="%_GlassDir%" goto EOF

:RegisterGlass
echo Running RegisterGlass.cmd...
call "%_GlassDir%RegisterGlass.cmd"
if NOT "%ERRORLEVEL%"=="0" echo ERROR: Unable to register glass. Ensure that this command prompt is elevated.& goto :EOF
call "%~dp0..\RegisterMIEngine.cmd"
if NOT "%ERRORLEVEL%"=="0" echo ERROR: Unable to register MIEngine.& goto :EOF
set ERRORLEVEL=0
goto EOF

:SetCurrentGlassRegRoot
REM %1 contains the glass install root. Unfortunately, if the path to the has spaces in it,
REM these will get broken up with each chunk in a different token. Lets try to put these tokens
REM back together.
set CurrentGlassRegRoot=%1
if "%2"=="%%b" goto EOF
if "%2"=="" goto EOF
if "%2"=="d" goto EOF
set CurrentGlassRegRoot=%1 %2
if "%3"=="%%c" goto EOF
if "%3"=="" goto EOF
if "%3"=="e" goto EOF
set CurrentGlassRegRoot=%1 %2 %3
if "%4"=="%%d" goto EOF
if "%4"=="" goto EOF
set CurrentGlassRegRoot=%1 %2 %3 %4
if "%5"=="%%e" goto EOF
if "%5"=="" goto EOF
set CurrentGlassRegRoot=%1 %2 %3 %4 %5
goto EOF

:EnsureLaunchOptionsGenBuilt
if not exist %_GlassDir%LaunchOptionsGen.exe echo Building LaunchOptionsGen.exe& msbuild /p:Configuration=Release;OutDir=%_GlassDir% /v:quiet %~dp0..\LaunchOptionsGen\LaunchOptionsGen.csproj
exit /b 0

:SetProjectRoot
set _ProjectRoot=%~f1
goto EOF

:Help
echo --- MIEngine Android Test Script ---
echo Usage: androidtest.cmd /DeviceId ^<id^> /Platform ^<platform^> [/SdkRoot ^<path^>] [/NdkRoot ^<path^>] [/v] [/Loop ^<num_iterations^>] [/Tests ^<test 1^> [^<test 2^> [...]]]
echo.
echo --- Examples ---
echo Run All Tests:
echo androidtest.cmd /DeviceId 169.254.138.123:5555 /Platform x86
echo.
echo Run two specific tests:
echo androidtest.cmd /DeviceId 169.254.138.123:5555 /Platform x86 /Tests Stepping Exceptions
echo.

if exist "%_SdkRoot%" "%_SdkRoot%\platform-tools\adb.exe" devices -l

:EOF

exit when no emulator is avaiable

exit when no emulator is avaiable


@rem MinGW build test - used to test MinGW builds locally
@rem Adapt path/versions before use

@rem This batch file must be used from the repository root
@if exist mingw.bat cd ..

@set PATH=%ProgramFiles%\mingw-w64\i686-4.9.2-win32-dwarf-rt_v3-rev1\mingw32\bin;%PATH%
@set PATH=%ProgramFiles%\GnuWin32\bin;%PATH%

@rem Alternative ways to use mingw
@rem make CC=gcc CFLAGS=-w CFLAGS+=-Iinclude/ CFLAGS+=-lws2_32 CFLAGS+=-liphlpapi
@rem gcc src\civetweb.c src\main.c -Iinclude\ -lws2_32 -lpthread -lcomdlg32 -w

make build CC=gcc WITH_LUA=1 WITH_WEBSOCKET=1

Add a helper script to test MinGW builds locally (to help debugging the build server)


@Echo off

for /f "delims=" %%i in ('PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.IO.Path]::GetTempFileName()"') do set DNVM_CMD_PATH_FILE=%%i

PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';$CmdPathFile='%DNVM_CMD_PATH_FILE%';& '%~dp0dnvm.ps1' %*"

IF EXIST %DNVM_CMD_PATH_FILE% (
  CALL %DNVM_CMD_PATH_FILE%
  DEL %DNVM_CMD_PATH_FILE%
)

@Echo off

for /f "delims=" %%i in ('PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.IO.Path]::GetTempFileName()"') do set DNVM_CMD_PATH_FILE=%%i.cmd

PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';$CmdPathFile='%DNVM_CMD_PATH_FILE%';& '%~dp0dnvm.ps1' %*"

IF EXIST %DNVM_CMD_PATH_FILE% (
  CALL %DNVM_CMD_PATH_FILE%
  DEL %DNVM_CMD_PATH_FILE%
)

Update dnvm.cmd

Update dnvm.cmd


@echo off

SETLOCAL

@rem Modified version of vcbuild.bat from Node
if /i "%1"=="help" goto help
if /i "%1"=="--help" goto help
if /i "%1"=="-help" goto help
if /i "%1"=="/help" goto help
if /i "%1"=="?" goto help
if /i "%1"=="-?" goto help
if /i "%1"=="--?" goto help
if /i "%1"=="/?" goto help

@rem Store %~dp0 because it can change after we call things
set scriptroot=%~dp0

@rem Process arguments.
set config=Release
set target=Build
set nobuild=
set noprojgen=
set rebuildnode=

:next-arg
if "%1"=="" goto args-done
if /i "%1"=="debug"         set config=Debug&goto arg-ok
if /i "%1"=="release"       set config=Release&goto arg-ok
if /i "%1"=="noprojgen"     set noprojgen=1&goto arg-ok
if /i "%1"=="nobuild"       set nobuild=1&goto arg-ok
if /i "%1"=="rebuild-node"  set rebuildnode=force&goto arg-ok

echo Warning: ignoring invalid command line option `%1`.

:arg-ok
shift
goto next-arg

:args-done

:install-deps
@rem Install all the node module dependencies
call yarn
if errorlevel 1 goto install-failed
echo JS modules installed.
goto find-vs-2015

:find-vs-2015
@rem Look for Visual Studio 2015
echo Looking for Visual Studio 2015
if not defined VS140COMNTOOLS goto vs-not-found
if not exist "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vs-not-found
echo Found Visual Studio 2015
if "%VCVARS_VER%" NEQ "140" (
  call "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat"
  SET VCVARS_VER=140
)
if not defined VCINSTALLDIR goto vs-not-found
set GYP_MSVS_VERSION=2015
set PLATFORM_TOOLSET=v140
goto build-node

:build-node
SETLOCAL
  call "%scriptroot%\tools\update-node\update-node.bat" %rebuildnode%
  if errorlevel 1 goto build-node-failed
ENDLOCAL

:project-gen
@rem Skip project generation if requested.
if defined noprojgen goto msbuild

:gen-vs-project
@rem Generate the VS project.
SETLOCAL
  cd "%scriptroot%"
  call "tools\gyp\gyp.bat" --depth=. -f msvs --generator-output=. -G msvs_version=auto -Icommon.gypi game.gyp
  if errorlevel 1 goto create-msvs-files-failed
  if not exist game.sln goto create-msvs-files-failed
  echo Game project files generated.
ENDLOCAL

:msbuild
@rem Skip build if requested.
if defined nobuild goto install-js-deps
goto do-build

:do-build
@rem Build the sln with msbuild.
SETLOCAL
  cd "%scriptroot%"
  msbuild game.sln /m /t:%target% /p:Configuration=%config% /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
ENDLOCAL
goto exit

:build-node-failed
echo Failed to build node.
goto exit

:create-msvs-files-failed
echo Failed to create VS project files for Shieldbattery.
goto exit

:install-failed
echo Installing JS modules failed, please check output and ensure node/npm are installed and setup on your PATH.
goto exit

:env-error
echo Necessary environment variables not set! Please set SHIELDBATTERY_PATH and re-run this script.
goto exit

:vs-not-found
echo Visual Studio 2015 could not be found! Please ensure its installed and setup correctly.
goto exit

:help
echo vcbuild.bat [debug/release] [noprojgen] [nobuild] [rebuild-node]
echo Examples:
echo   vcbuild.bat                : builds release build
echo   vcbuild.bat debug          : builds debug build
goto exit

:exit
goto :EOF

@echo off

SETLOCAL

@rem Modified version of vcbuild.bat from Node
if /i "%1"=="help" goto help
if /i "%1"=="--help" goto help
if /i "%1"=="-help" goto help
if /i "%1"=="/help" goto help
if /i "%1"=="?" goto help
if /i "%1"=="-?" goto help
if /i "%1"=="--?" goto help
if /i "%1"=="/?" goto help

@rem Store %~dp0 because it can change after we call things
set scriptroot=%~dp0

@rem Process arguments.
set config=Release
set target=Build
set nobuild=
set noprojgen=
set rebuildnode=

:next-arg
if "%1"=="" goto args-done
if /i "%1"=="debug"         set config=Debug&goto arg-ok
if /i "%1"=="release"       set config=Release&goto arg-ok
if /i "%1"=="noprojgen"     set noprojgen=1&goto arg-ok
if /i "%1"=="nobuild"       set nobuild=1&goto arg-ok
if /i "%1"=="rebuild-node"  set rebuildnode=force&goto arg-ok

echo Warning: ignoring invalid command line option `%1`.

:arg-ok
shift
goto next-arg

:args-done

:install-deps
@rem Install all the node module dependencies
call yarn
if errorlevel 1 goto install-failed
echo JS modules installed.
goto find-vs-2015

:find-vs-2015
@rem Look for Visual Studio 2015
echo Looking for Visual Studio 2015
if not defined VS140COMNTOOLS goto vs-not-found
if not exist "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vs-not-found
echo Found Visual Studio 2015
if "%VCVARS_VER%" NEQ "140" (
  call "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat"
  SET VCVARS_VER=140
)
if not defined VCINSTALLDIR goto vs-not-found
set GYP_MSVS_VERSION=2015
set PLATFORM_TOOLSET=v140
goto build-node

:build-node
SETLOCAL
  call "%scriptroot%\tools\update-node\update-node.bat" %rebuildnode%
  if errorlevel 1 goto build-node-failed
ENDLOCAL

:project-gen
@rem Skip project generation if requested.
if defined noprojgen goto msbuild

:gen-vs-project
@rem Generate the VS project.
SETLOCAL
  cd "%scriptroot%"
  call "tools\gyp\gyp.bat" --depth=. -f msvs --generator-output=. -G msvs_version=auto -Icommon.gypi game.gyp
  if errorlevel 1 goto create-msvs-files-failed
  if not exist game.sln goto create-msvs-files-failed
  echo Game project files generated.
ENDLOCAL

:msbuild
@rem Skip build if requested.
if defined nobuild goto install-js-deps
goto do-build

:do-build
@rem Build the sln with msbuild.
SETLOCAL
  cd "%scriptroot%"
  msbuild game.sln /m /t:%target% /p:Configuration=%config% /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
ENDLOCAL
goto exit

:build-node-failed
echo Failed to build node.
goto exit

:create-msvs-files-failed
echo Failed to create VS project files for Shieldbattery.
goto exit

:install-failed
echo Installing JS modules failed, please check output and ensure node/npm are installed and setup on your PATH.
goto exit

:vs-not-found
echo Visual Studio 2015 could not be found! Please ensure its installed and setup correctly.
goto exit

:help
echo vcbuild.bat [debug/release] [noprojgen] [nobuild] [rebuild-node]
echo Examples:
echo   vcbuild.bat                : builds release build
echo   vcbuild.bat debug          : builds debug build
goto exit

:exit
goto :EOF

Remove final reference to SHIELDBATTERY_PATH in game/.


@echo off

echo Building dependencies...

if exist lib (rd lib /q /s)
md lib
cd lib
md Debug
md Release
cd ../

REM If your path is different with blow, please change to your install path
set %VS150COMNTOOLS%=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\
echo "%VS150COMNTOOLS%..\IDE\Devenv"

REM ######################################################################################################
echo Building protobuf...

if exist protobuf (rd protobuf /q /s)
git clone -b 3.5.x https://github.com/google/protobuf.git

cd protobuf/cmake
md build
cd build
cmake -G "Visual Studio 15 Win64" -Dprotobuf_BUILD_SHARED_LIBS=ON -Dprotobuf_BUILD_TESTS=OFF ..
"%VS150COMNTOOLS%..\IDE\Devenv" protobuf.sln /build "Debug|x64"
"%VS150COMNTOOLS%..\IDE\Devenv" protobuf.sln /build "Release|x64"
copy Debug\*.dll ..\..\..\lib\Debug /Y
copy Debug\*.lib ..\..\..\lib\Debug /Y
copy Release\*.dll ..\..\..\lib\Release /Y
copy Release\*.lib ..\..\..\lib\Release /Y

copy Release\libprotobuf.dll ..\..\..\..\Frame\SDK\Proto\proto-gen /Y
copy Release\libprotoc.dll ..\..\..\..\Frame\SDK\Proto\proto-gen /Y
copy Release\protoc.exe ..\..\..\..\Frame\SDK\Proto\proto-gen /Y

cd ..\..\..\
REM ######################################################################################################
echo Building libevent...

if exist libevent (rd libevent /q /s)
git clone -b master https://github.com/libevent/libevent.git

cd libevent
md build
cd build
cmake -G "Visual Studio 15 Win64" -DEVENT__DISABLE_OPENSSL=ON ..
"%VS150COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Debug|x64" /project event_core_static.vcxproj
"%VS150COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Release|x64" /project event_core_static.vcxproj
"%VS150COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Debug|x64" /project event_static.vcxproj
"%VS150COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Release|x64" /project event_static.vcxproj
"%VS150COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Debug|x64" /project event_extra_static.vcxproj
"%VS150COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Release|x64" /project event_extra_static.vcxproj
copy lib\Debug\*.lib ..\..\lib\Debug /Y
copy lib\Release\*.lib ..\..\lib\Release /Y
cd ..\..\
REM ######################################################################################################
echo Building evpp...
if exist evpp (rd evpp /q /s)
git clone -b master https://github.com/ArkGame/evpp.git

cd evpp
md build
cd build
cmake -G "Visual Studio 15 Win64" -DLIBEVENT_DIR=..\libevent -DLIBEVENT_LIB_DIR=..\lib\Release ..
"%VS150COMNTOOLS%..\IDE\Devenv" evpp.sln /build "Debug|x64" /project evpp/evpp_static.vcxproj
"%VS150COMNTOOLS%..\IDE\Devenv" evpp.sln /build "Release|x64" /project evpp/evpp_static.vcxproj
copy lib\Debug\*.lib ..\..\lib\Debug /Y
copy lib\Release\*.lib ..\..\lib\Release /Y

cd ..\..\
REM ####################################################################################################
REM back to root dir
cd ..\

@echo off

echo Building dependencies...

if exist lib (rd lib /q /s)
md lib
cd lib
md Debug
md Release
cd ../

REM If your path is different with below, please change to your install path
set %VS150COMNTOOLS%=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\
echo "%VS150COMNTOOLS%..\IDE\Devenv"

REM ######################################################################################################
echo Building protobuf...

if exist protobuf (rd protobuf /q /s)
git clone -b 3.5.x https://github.com/google/protobuf.git

cd protobuf/cmake
md build
cd build
cmake -G "Visual Studio 15 Win64" -Dprotobuf_BUILD_SHARED_LIBS=ON -Dprotobuf_BUILD_TESTS=OFF ..
"%VS150COMNTOOLS%..\IDE\Devenv" protobuf.sln /build "Debug|x64"
"%VS150COMNTOOLS%..\IDE\Devenv" protobuf.sln /build "Release|x64"
copy Debug\*.dll ..\..\..\lib\Debug /Y
copy Debug\*.lib ..\..\..\lib\Debug /Y
copy Release\*.dll ..\..\..\lib\Release /Y
copy Release\*.lib ..\..\..\lib\Release /Y

copy Release\libprotobuf.dll ..\..\..\..\Frame\SDK\Proto\proto-gen /Y
copy Release\libprotoc.dll ..\..\..\..\Frame\SDK\Proto\proto-gen /Y
copy Release\protoc.exe ..\..\..\..\Frame\SDK\Proto\proto-gen /Y

cd ..\..\..\
REM ######################################################################################################
echo Building libevent...

if exist libevent (rd libevent /q /s)
git clone -b master https://github.com/libevent/libevent.git

cd libevent
md build
cd build
cmake -G "Visual Studio 15 Win64" -DEVENT__DISABLE_OPENSSL=ON ..
"%VS150COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Debug|x64" /project event_core_static.vcxproj
"%VS150COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Release|x64" /project event_core_static.vcxproj
"%VS150COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Debug|x64" /project event_static.vcxproj
"%VS150COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Release|x64" /project event_static.vcxproj
"%VS150COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Debug|x64" /project event_extra_static.vcxproj
"%VS150COMNTOOLS%..\IDE\Devenv" libevent.sln /build "Release|x64" /project event_extra_static.vcxproj
copy lib\Debug\*.lib ..\..\lib\Debug /Y
copy lib\Release\*.lib ..\..\lib\Release /Y
cd ..\..\
REM ######################################################################################################
echo Building evpp...
if exist evpp (rd evpp /q /s)
git clone -b master https://github.com/ArkGame/evpp.git

cd evpp
md build
cd build
cmake -G "Visual Studio 15 Win64" -DLIBEVENT_DIR=..\libevent -DLIBEVENT_LIB_DIR=..\lib\Release ..
"%VS150COMNTOOLS%..\IDE\Devenv" evpp.sln /build "Debug|x64" /project evpp/evpp_static.vcxproj
"%VS150COMNTOOLS%..\IDE\Devenv" evpp.sln /build "Release|x64" /project evpp/evpp_static.vcxproj
copy lib\Debug\*.lib ..\..\lib\Debug /Y
copy lib\Release\*.lib ..\..\lib\Release /Y

cd ..\..\
REM ####################################################################################################
REM back to root dir
cd ..\

Update build_dep_vs2017.bat

Update build_dep_vs2017.bat

Former-commit-id: c5a9c28e9abb6deedb90ec273e78e1f05da2684d
Former-commit-id: 909187435a24ee338e1a4320eb34d3b7d5387ee6


@echo //------------------------------------------------------------------------------
@echo // file:
@echo //    cmake.bat
@echo // brief:
@echo //    builds project by cmake
@echo // version:
@echo //    $Id: cmake.bat 365 2014-07-13 07:58:50Z hryky.private@gmail.com $
@echo //
@echo // usage:
@echo //    cmake_build.bat
@echo //
@echo // prerequisite variables:
@echo //    CMAKE_SRC_DIR   is the root directory containing source files.
@echo //    CMAKE_BIN_DIR   is the destination of CMake.
@echo //    CMAKE_COMMAND   is the built-in target of the building project.
@echo //                    [build or clean or test or rebuild or document or
@echo //                    install or pack]
@echo //    CMAKE_TARGET    is the individual target of the building project.
@echo //                    If the CMAKE_COMMAND is build, this argument
@echo //                    specifies an indivisual project. If the CMAKE_COMMAND
@echo //                    is test, this argument specifies an individual test.
@echo //   CMAKE_CONFIG     is the configuration of the building project.
@echo //                    [Debug or Release or RelWithDebInfo or MinSizeRel]
@echo //------------------------------------------------------------------------------

@setlocal enableextensions enabledelayedexpansion

@if not defined CMAKE_SRC_DIR @(
	@echo %~f0 : error : CMAKE_SRC_DIR is not defined.
	@exit /b 1
)

@if not defined CMAKE_BIN_DIR @(
	@echo %~f0 : error : CMAKE_BIN_DIR is not defined.
	@exit /b 1
)

@if "" == "%CMAKE_CONFIG%" @(
	@set CMAKE_CONFIG=Debug
)

@REM // The verbosity of output
@REM //  q[uiet]
@REM //  m[inimal]
@REM //  n[ormal]
@REM //  d[etailed]
@REM //  diag[nostic]
@set MSBUILD_VERBOSITY=m

@set CMAKE_BUILD_FLAGS=^
    --build "%CMAKE_BIN_DIR%" ^
    --config %CMAKE_CONFIG%

@set CMAKE_BUILD_FLAGS_NATIVE=^
    /m ^
    /nologo ^
    /verbosity:%MSBUILD_VERBOSITY% ^
    /clp:DisableMPLogging

@set CPACK_FLAGS=^
    --config "%CMAKE_BIN_DIR%/CPackConfig.cmake" ^
    -C "%CMAKE_CONFIG%"

@set CTEST_FLAGS=^
    --parallel 8 ^
    --output-on-failure ^
    -vv ^
    -C "%CMAKE_CONFIG%"

call %DEVROOT%/hryky-codebase/tool/build/define_variables.bat

REM call %SETUPMSSDK%
REM @if errorlevel 1 @goto error

@if not defined CMAKEGENERATOR @(
	@echo %~f0 : error : CMAKEGENERATOR is not defined.
	@exit /b 1
)

"%CMAKE%" -E make_directory %CMAKE_BIN_DIR%

@set CMAKE_CONFIGURE_FLAGS=^
    -G "%CMAKEGENERATOR%" ^
    -DHRYKY_CMAKE_VERBOSITY:STRING=1

@echo change directory to %CMAKE_BIN_DIR% for out-of-source build.
@pushd %CMAKE_BIN_DIR:/=\%

@if not "" == "%CMAKE_TARGET%" @(
	@if "%CMAKE_COMMAND%" == "test" @(
		@set CTEST_REGEX=-R %CMAKE_TARGET%
	) else @(
		@set CMAKE_BUILD_TARGET=--target %CMAKE_TARGET%
	)
)

:main

@if "%CMAKE_COMMAND%" == "configure" @(
	call :configure
	@if errorlevel 1 @exit /b 1

	goto :success
)

@if "%CMAKE_COMMAND%" == "build" @(
	call :build
	@if errorlevel 1 @exit /b 1

	goto :success
)

@if "%CMAKE_COMMAND%" == "clean" @(
	call :clean
	@if errorlevel 1 @exit /b 1

	goto :success
)

@if "%CMAKE_COMMAND%" == "test" @(
	call :build
	@if errorlevel 1 @exit /b 1

	call :test
	@if errorlevel 1 @exit /b 1

	goto :success
)

@if "%CMAKE_COMMAND%" == "rebuild" @(
	call :rebuild
	@if errorlevel 1 @exit /b 1

	goto :success
)

@if "%CMAKE_COMMAND%" == "document" @(
	call :document
	@if errorlevel 1 @exit /b 1

	goto :success
)

@if "%CMAKE_COMMAND%" == "install" @(
	call :install
	@if errorlevel 1 @exit /b 1

	call :pack
	@if errorlevel 1 @exit /b 1

	goto :success
)

@if "%CMAKE_COMMAND%" == "pack" @(
	call :pack
	@if errorlevel 1 @exit /b 1

	goto :success
)

@echo //----------------------------------------------------------------
@echo // default process.
@echo //----------------------------------------------------------------
call :configure
@if errorlevel 1 @exit /b 1

call :build
@if errorlevel 1 @exit /b 1

call :test
@if errorlevel 1 @exit /b 1

goto :success

:configure
@echo //------------------------------------------------------------------------------
@echo // configuration
@echo //------------------------------------------------------------------------------
"%CMAKE%" ^
	%CMAKE_CONFIGURE_FLAGS% ^
	%CMAKE_SRC_DIR%
@if errorlevel 1 @(
	@echo %~f0 : error : configuration process failed.
	@exit /b 1
)
@exit /b 0

:build
@echo //------------------------------------------------------------------------------
@echo // build
@echo //------------------------------------------------------------------------------
"%CMAKE%" ^
	%CMAKE_BUILD_FLAGS% ^
	%CMAKE_BUILD_TARGET% ^
	-- %CMAKE_BUILD_FLAGS_NATIVE%
	@rem | "%SED%" "s/ \+[0-9]\+>//g"
@if errorlevel 1 @(
	@echo %~f0 : error : build process failed.
	@exit /b 1
)
@exit /b 0

:clean
@echo //------------------------------------------------------------------------------
@echo // clean
@echo //------------------------------------------------------------------------------
"%CMAKE%" ^
	%CMAKE_BUILD_FLAGS% ^
	--target clean ^
	-- %CMAKE_BUILD_FLAGS_NATIVE%
@if errorlevel 1 @(
	@echo %~f0 : error : clean process failed.
	@exit /b 1
)
@exit /b 0

:rebuild
@echo //------------------------------------------------------------------------------
@echo // rebuild
@echo //------------------------------------------------------------------------------
"%CMAKE%" ^
	%CMAKE_BUILD_FLAGS% ^
	--clean-first ^
	%CMAKE_BUILD_TARGET% ^
	-- %CMAKE_BUILD_FLAGS_NATIVE%
	@rem | "%SED%" "s/ \+[0-9]\+>//g"
@if errorlevel 1 @(
	@echo %~f0 : error : rebuild process failed.
	@exit /b 1
)
@exit /b 0

:test
@echo //------------------------------------------------------------------------------
@echo // testing
@echo //------------------------------------------------------------------------------
"%CTEST%" ^
	%CTEST_FLAGS% ^
	%CTEST_REGEX%
@if errorlevel 1 @(
	@echo %~f0 : error : test process failed.
	@exit /b 1
)
@exit /b 0

:document
@echo //------------------------------------------------------------------------------
@echo // generates document
@echo //------------------------------------------------------------------------------
"%CMAKE%" ^
	%CMAKE_BUILD_FLAGS% ^
	--target doc_hryky_codebase
@if errorlevel 1 @(
	@echo %~f0 : error : running doxygen failed.
	@exit /b 1
)
@exit /b 0

:install
@echo //------------------------------------------------------------------------------
@echo // installation
@echo //------------------------------------------------------------------------------
"%CMAKE%" ^
	%CMAKE_BUILD_FLAGS% ^
	--target INSTALL
@if errorlevel 1 @(
	@echo %~f0 : error : test process failed.
	@exit /b 1
)
@exit /b 0

:pack
@echo //------------------------------------------------------------------------------
@echo // packing
@echo //------------------------------------------------------------------------------
"%CPACK%" ^
	-G "NSIS" ^
	%CPACK_FLAGS%
@if errorlevel 1 @(
	@echo %~f0 : error : pack process failed.
	@exit /b 1
)
@exit /b 0

:success

@echo //------------------------------------------------------------------------------
@echo // cmake for '%CMAKE_SRC_DIR%' succeeded
@echo //------------------------------------------------------------------------------
@popd
@exit /b 0

@endlocal

@echo //------------------------------------------------------------------------------
@echo // file:
@echo //    cmake.bat
@echo // brief:
@echo //    builds project by cmake
@echo // version:
@echo //    $Id: cmake.bat 365 2014-07-13 07:58:50Z hryky.private@gmail.com $
@echo //
@echo // usage:
@echo //    cmake_build.bat
@echo //
@echo // prerequisite variables:
@echo //    CMAKE_SRC_DIR   is the root directory containing source files.
@echo //    CMAKE_BIN_DIR   is the destination of CMake.
@echo //    CMAKE_COMMAND   is the built-in target of the building project.
@echo //                    [build or clean or test or rebuild or document or
@echo //                    install or pack]
@echo //    CMAKE_TARGET    is the individual target of the building project.
@echo //                    If the CMAKE_COMMAND is build, this argument
@echo //                    specifies an indivisual project. If the CMAKE_COMMAND
@echo //                    is test, this argument specifies an individual test.
@echo //   CMAKE_CONFIG     is the configuration of the building project.
@echo //                    [Debug or Release or RelWithDebInfo or MinSizeRel]
@echo //------------------------------------------------------------------------------

@setlocal enableextensions enabledelayedexpansion

@if not defined CMAKE_SRC_DIR @(
	@echo %~f0 : error : CMAKE_SRC_DIR is not defined.
	@exit /b 1
)

@if not defined CMAKE_BIN_DIR @(
	@echo %~f0 : error : CMAKE_BIN_DIR is not defined.
	@exit /b 1
)

@if "" == "%CMAKE_CONFIG%" @(
	@set CMAKE_CONFIG=Debug
)

@REM // The verbosity of output
@REM //  q[uiet]
@REM //  m[inimal]
@REM //  n[ormal]
@REM //  d[etailed]
@REM //  diag[nostic]
@set MSBUILD_VERBOSITY=m

@set CMAKE_VERBOSITY=^
    -DHRYKY_CMAKE_VERBOSITY:STRING=1

@set CMAKE_BUILD_FLAGS=^
    --build "%CMAKE_BIN_DIR%" ^
    --config %CMAKE_CONFIG%

@set CMAKE_BUILD_FLAGS_NATIVE=^
    /m ^
    /nologo ^
    /verbosity:%MSBUILD_VERBOSITY% ^
    /clp:DisableMPLogging

@set CPACK_FLAGS=^
    --config "%CMAKE_BIN_DIR%/CPackConfig.cmake" ^
    -C "%CMAKE_CONFIG%"

@set CTEST_FLAGS=^
    --parallel 8 ^
    --output-on-failure ^
    -vv ^
    -C "%CMAKE_CONFIG%"

call %DEVROOT%/hryky-codebase/tool/build/define_variables.bat

REM call %SETUPMSSDK%
REM @if errorlevel 1 @goto error

@if not defined CMAKEGENERATOR @(
	@echo %~f0 : error : CMAKEGENERATOR is not defined.
	@exit /b 1
)

"%CMAKE%" -E make_directory %CMAKE_BIN_DIR%

@set CMAKE_CONFIGURE_FLAGS=^
    -G "%CMAKEGENERATOR%" ^
    "%CMAKE_VERBOSITY%"

@echo change directory to %CMAKE_BIN_DIR% for out-of-source build.
@pushd %CMAKE_BIN_DIR:/=\%

@if not "" == "%CMAKE_TARGET%" @(
	@if "%CMAKE_COMMAND%" == "test" @(
		@set CTEST_REGEX=-R %CMAKE_TARGET%
	) else @(
		@set CMAKE_BUILD_TARGET=--target %CMAKE_TARGET%
	)
)

:main

@if "%CMAKE_COMMAND%" == "configure" @(
	call :configure
	@if errorlevel 1 @exit /b 1

	goto :success
)

@if "%CMAKE_COMMAND%" == "build" @(
	call :build
	@if errorlevel 1 @exit /b 1

	goto :success
)

@if "%CMAKE_COMMAND%" == "clean" @(
	call :clean
	@if errorlevel 1 @exit /b 1

	goto :success
)

@if "%CMAKE_COMMAND%" == "test" @(
	call :build
	@if errorlevel 1 @exit /b 1

	call :test
	@if errorlevel 1 @exit /b 1

	goto :success
)

@if "%CMAKE_COMMAND%" == "rebuild" @(
	call :rebuild
	@if errorlevel 1 @exit /b 1

	goto :success
)

@if "%CMAKE_COMMAND%" == "document" @(
	call :document
	@if errorlevel 1 @exit /b 1

	goto :success
)

@if "%CMAKE_COMMAND%" == "install" @(
	call :install
	@if errorlevel 1 @exit /b 1

	call :pack
	@if errorlevel 1 @exit /b 1

	goto :success
)

@if "%CMAKE_COMMAND%" == "pack" @(
	call :pack
	@if errorlevel 1 @exit /b 1

	goto :success
)

@echo //----------------------------------------------------------------
@echo // default process.
@echo //----------------------------------------------------------------
call :configure
@if errorlevel 1 @exit /b 1

call :build
@if errorlevel 1 @exit /b 1

call :test
@if errorlevel 1 @exit /b 1

goto :success

:configure
@echo //------------------------------------------------------------------------------
@echo // configuration
@echo //------------------------------------------------------------------------------
"%CMAKE%" ^
	%CMAKE_CONFIGURE_FLAGS% ^
	%CMAKE_SRC_DIR%
@if errorlevel 1 @(
	@echo %~f0 : error : configuration process failed.
	@exit /b 1
)
@exit /b 0

:build
@echo //------------------------------------------------------------------------------
@echo // build
@echo //------------------------------------------------------------------------------
"%CMAKE%" ^
	%CMAKE_BUILD_FLAGS% ^
	%CMAKE_BUILD_TARGET% ^
	-- %CMAKE_BUILD_FLAGS_NATIVE%
	@rem | "%SED%" "s/ \+[0-9]\+>//g"
@if errorlevel 1 @(
	@echo %~f0 : error : build process failed.
	@exit /b 1
)
@exit /b 0

:clean
@echo //------------------------------------------------------------------------------
@echo // clean
@echo //------------------------------------------------------------------------------
"%CMAKE%" ^
	%CMAKE_BUILD_FLAGS% ^
	--target clean ^
	-- %CMAKE_BUILD_FLAGS_NATIVE%
@if errorlevel 1 @(
	@echo %~f0 : error : clean process failed.
	@exit /b 1
)
@exit /b 0

:rebuild
@echo //------------------------------------------------------------------------------
@echo // rebuild
@echo //------------------------------------------------------------------------------
"%CMAKE%" ^
	%CMAKE_BUILD_FLAGS% ^
	--clean-first ^
	%CMAKE_BUILD_TARGET% ^
	-- %CMAKE_BUILD_FLAGS_NATIVE%
	@rem | "%SED%" "s/ \+[0-9]\+>//g"
@if errorlevel 1 @(
	@echo %~f0 : error : rebuild process failed.
	@exit /b 1
)
@exit /b 0

:test
@echo //------------------------------------------------------------------------------
@echo // testing
@echo //------------------------------------------------------------------------------
"%CTEST%" ^
	%CTEST_FLAGS% ^
	%CTEST_REGEX%
@if errorlevel 1 @(
	@echo %~f0 : error : test process failed.
	@exit /b 1
)
@exit /b 0

:document
@echo //------------------------------------------------------------------------------
@echo // generates document
@echo //------------------------------------------------------------------------------
"%CMAKE%" ^
	%CMAKE_BUILD_FLAGS% ^
	--target doc_hryky_codebase
@if errorlevel 1 @(
	@echo %~f0 : error : running doxygen failed.
	@exit /b 1
)
@exit /b 0

:install
@echo //------------------------------------------------------------------------------
@echo // installation
@echo //------------------------------------------------------------------------------
"%CMAKE%" ^
	%CMAKE_BUILD_FLAGS% ^
	--target INSTALL
@if errorlevel 1 @(
	@echo %~f0 : error : test process failed.
	@exit /b 1
)
@exit /b 0

:pack
@echo //------------------------------------------------------------------------------
@echo // packing
@echo //------------------------------------------------------------------------------
"%CPACK%" ^
	-G "NSIS" ^
	%CPACK_FLAGS%
@if errorlevel 1 @(
	@echo %~f0 : error : pack process failed.
	@exit /b 1
)
@exit /b 0

:success

@echo //------------------------------------------------------------------------------
@echo // cmake for '%CMAKE_SRC_DIR%' succeeded
@echo //------------------------------------------------------------------------------
@popd
@exit /b 0

@endlocal

create a variable to store the verbosity


@echo off
rem This will download the Kolibri windows installer artifact at the windows-2016 buildkite agent.
rem After the installer successfully sign it will upload the signed installer at the Sign Windows installer pipeline artifact.
rem To sign the Windows installer set the `SIGN_WINDOWS_INSTALLER=true` environment variable.

IF NOT "%SIGN_WINDOWS_INSTALLER%" == "true" (GOTO DONT_SIGN)

set current_path=%cd%
buildkite-agent.exe artifact download "installer/*.exe" . --step "Build kolibri windows installer" --build %BUILDKITE_BUILD_ID% --agent-access-token %BUILDKITE_AGENT_ACCESS_TOKEN%
%WINDOWS_SIGN_SCRIPT_PATH% "%current_path%\installer" && cd "%current_path%\installer\" && buildkite-agent.exe artifact upload "*.exe"
GOTO END

:DONT_SIGN
echo Don't sign the Windows installer.

:END

@echo off
rem This will download the Kolibri windows installer artifact at the windows-2016 buildkite agent.
rem After the installer successfully sign it will upload the signed installer at the Sign Windows installer pipeline artifact.
rem To sign the Windows installer set the `SIGN_WINDOWS_INSTALLER=true` environment variable.

IF NOT "%SIGN_WINDOWS_INSTALLER%" == "true" (GOTO DONT_SIGN)

set current_path=%cd%
buildkite-agent.exe artifact download "installer/*.exe" . --step "Build kolibri windows installer" --build %BUILDKITE_BUILD_ID% --agent-access-token %BUILDKITE_AGENT_ACCESS_TOKEN%
%WINDOWS_SIGN_SCRIPT_PATH% "%current_path%\installer" && cd "%current_path%\installer\" && buildkite-agent.exe artifact upload "*.exe"
GOTO END

:DONT_SIGN
echo Set the SIGN_WINDOWS_INSTALLER=true environment variable to sign the Windows installer.

:END

Change the don’t sign message log.

Change the don’t sign message log.