@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off

:: ----------------------
:: KUDU Deployment Script
:: Version: 1.0.6
:: ----------------------

:: Prerequisites
:: -------------

:: Verify node.js installed
where node 2>nul >nul
IF %ERRORLEVEL% NEQ 0 (
  echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment.
  goto error
)

:: Setup
:: -----
:: Setup npm global path to d:\home

echo Print variables
echo dp0=%~dp0%
echo ARTIFACTS=%ARTIFACTS%
echo DEPLOYMENT_SOURCE=%DEPLOYMENT_SOURCE%
echo DEPLOYMENT_TARGET=%DEPLOYMENT_TARGET%
echo DEPLOYMENT_TARGET_ANGULAR=%DEPLOYMENT_TARGET_ANGULAR%
echo NEXT_MANIFEST_PATH=%NEXT_MANIFEST_PATH%
echo PREVIOUS_MANIFEST_PATH=%PREVIOUS_MANIFEST_PATH%
echo DEPLOYMENT_TEMP=%DEPLOYMENT_TEMP%
echo IN_PLACE_DEPLOYMENT=%IN_PLACE_DEPLOYMENT%
echo ANGUALR_CLI=%ANGUALR_CLI%

setlocal enabledelayedexpansion

SET ARTIFACTS=%~dp0%..\artifacts

IF NOT DEFINED DEPLOYMENT_SOURCE (
	SET DEPLOYMENT_SOURCE=%~dp0%.
	echo SET DEPLOYMENT_SOURCE
)

IF NOT DEFINED DEPLOYMENT_TARGET (
  SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot
)

IF NOT DEFINED NEXT_MANIFEST_PATH (
  SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest

  IF NOT DEFINED PREVIOUS_MANIFEST_PATH (
    SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest
  )
)

IF NOT DEFINED NEXT_CLIENT_MANIFEST_PATH (
  SET NEXT_CLIENT_MANIFEST_PATH=%ARTIFACTS%\client-manifest

  IF NOT EXIST "%NEXT_CLIENT_MANIFEST_PATH%" (MKDIR "%NEXT_CLIENT_MANIFEST_PATH%")

  IF NOT DEFINED PREVIOUS_CLIENT_MANIFEST_PATH (
    SET PREVIOUS_CLIENT_MANIFEST_PATH=%ARTIFACTS%\client-manifest
  )

  IF NOT EXIST "%PREVIOUS_CLIENT_MANIFEST_PATH%" (MKDIR "%PREVIOUS_CLIENT_MANIFEST_PATH%")
)

IF NOT EXIST "%HOME%\tools" (MKDIR "%HOME%\tools")

SET PATH=%PATH%;%HOME%\tools

call npm config set prefix "%HOME%\tools"
IF !ERRORLEVEL! NEQ 0 goto error

IF NOT DEFINED KUDU_SYNC_CMD (
  :: Install kudu sync
  echo Installing Kudu Sync
  call npm install kudusync -g --silent
  IF !ERRORLEVEL! NEQ 0 goto error

  :: Locally just running "kuduSync" would also work
  SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd
)

IF NOT DEFINED ANGUALR_CLI (
  :: Install angular-cli
  echo Installing angular-cli
  call npm install -g angular-cli@1.0.0-beta.19-3

  IF !ERRORLEVEL! NEQ 0 goto error

  SET ANGUALR_CLI=true
)

IF NOT DEFINED DEPLOYMENT_TEMP (
  SET DEPLOYMENT_TEMP=%temp%\___deployTemp%random%
  SET CLEAN_LOCAL_DEPLOYMENT_TEMP=true
)

IF DEFINED CLEAN_LOCAL_DEPLOYMENT_TEMP (
  IF EXIST "%DEPLOYMENT_TEMP%" rd /s /q "%DEPLOYMENT_TEMP%"
  mkdir "%DEPLOYMENT_TEMP%"
)

IF DEFINED MSBUILD_PATH goto MsbuildPathDefined
SET MSBUILD_PATH=%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe
:MsbuildPathDefined

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------

echo Print variables
echo dp0=%~dp0%
echo ARTIFACTS=%ARTIFACTS%
echo DEPLOYMENT_SOURCE=%DEPLOYMENT_SOURCE%
echo DEPLOYMENT_TARGET=%DEPLOYMENT_TARGET%
echo DEPLOYMENT_TARGET_ANGULAR=%DEPLOYMENT_TARGET_ANGULAR%
echo NEXT_MANIFEST_PATH=%NEXT_MANIFEST_PATH%
echo PREVIOUS_MANIFEST_PATH=%PREVIOUS_MANIFEST_PATH%
echo DEPLOYMENT_TEMP=%DEPLOYMENT_TEMP%
echo IN_PLACE_DEPLOYMENT=%IN_PLACE_DEPLOYMENT%
echo ANGUALR_CLI=%ANGUALR_CLI%

echo Handling backend WebApi project.
echo Restore NuGet packages
IF /I "AzureFunctions.sln" NEQ "" (
  call :ExecuteCmd nuget restore "%DEPLOYMENT_SOURCE%\AzureFunctions.sln"
  IF !ERRORLEVEL! NEQ 0 goto error
)

:: 1. Build backend WebApi to the temporary path
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  echo "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\AzureFunctions\AzureFunctions.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="%DEPLOYMENT_TEMP%";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false  /p:DeleteExistingFiles=False /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
  call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\AzureFunctions\AzureFunctions.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="%DEPLOYMENT_TEMP%";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false  /p:DeleteExistingFiles=False /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
) ELSE (
  call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\AzureFunctions\AzureFunctions.csproj" /nologo /verbosity:m /t:Build /p:AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false  /p:DeleteExistingFiles=False /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
)

echo Handling frontend Angular2 project.
:: 2. Bundle frontend angular2 app to the temporary path
IF EXIST "%DEPLOYMENT_SOURCE%\AzureFunctions.AngularClient\package.json" (

	IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
	echo ROBOCOPY "%DEPLOYMENT_SOURCE%\AzureFunctions.AngularClient" "%ARTIFACTS%\AzureFunctions.AngularClient" /E /IS
		call :ExecuteCmd ROBOCOPY "%DEPLOYMENT_SOURCE%\AzureFunctions.AngularClient" "%ARTIFACTS%\AzureFunctions.AngularClient" /E /IS
		:: http://ss64.com/nt/robocopy-exit.html
		IF %ERRORLEVEL% EQU 16 echo ***FATAL ERROR*** & goto error
		IF %ERRORLEVEL% EQU 15 echo OKCOPY + FAIL + MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 14 echo FAIL + MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 13 echo OKCOPY + FAIL + MISMATCHES & goto error
		IF %ERRORLEVEL% EQU 12 echo FAIL + MISMATCHES& goto error
		IF %ERRORLEVEL% EQU 11 echo OKCOPY + FAIL + XTRA & goto error
		IF %ERRORLEVEL% EQU 10 echo FAIL + XTRA & goto error
		IF %ERRORLEVEL% EQU 9 echo OKCOPY + FAIL & goto error
		IF %ERRORLEVEL% EQU 8 echo FAIL & goto error
		IF %ERRORLEVEL% EQU 7 echo OKCOPY + MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 6 echo MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 5 echo OKCOPY + MISMATCHES & goto error
		IF %ERRORLEVEL% EQU 4 echo MISMATCHES & goto error
		IF %ERRORLEVEL% EQU 3 echo OKCOPY + XTRA
		IF %ERRORLEVEL% EQU 2 echo XTRA
		IF %ERRORLEVEL% EQU 1 echo OKCOPY
		IF %ERRORLEVEL% EQU 0 echo No Change
	)

	pushd "%ARTIFACTS%\AzureFunctions.AngularClient"
	echo Restore npm packages
	call :ExecuteCmd npm install
	IF !ERRORLEVEL! NEQ 0 (
		call :ExecuteCmd npm install
		IF !ERRORLEVEL! NEQ 0 goto error
	)
	echo Bundle angular2 app
	call :ExecuteCmd ng build --prod --environment=prod --output-path="%ARTIFACTS%\AzureFunctions.AngularClient\dist"
	IF !ERRORLEVEL! NEQ 0 (
		call :ExecuteCmd ng build --prod --environment=prod --output-path="%ARTIFACTS%\AzureFunctions.AngularClient\dist"
		IF !ERRORLEVEL! NEQ 0 goto error
	)

	pushd "%ARTIFACTS%\AzureFunctions.AngularClient\dist"
		mv main.*.bundle.js main.bundle.js
		mv scripts.*.bundle.js scripts.bundle.js
		mv styles.*.bundle.js styles.bundle.js
	popd

	each Copy angular output to the temporary path
	IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
		echo ROBOCOPY "%ARTIFACTS%\AzureFunctions.AngularClient\dist" "%DEPLOYMENT_TEMP%" /E /IS
		call :ExecuteCmd ROBOCOPY "%ARTIFACTS%\AzureFunctions.AngularClient\dist" "%DEPLOYMENT_TEMP%" /E /IS
		:: http://ss64.com/nt/robocopy-exit.html
		IF %ERRORLEVEL% EQU 16 echo ***FATAL ERROR*** & goto error
		IF %ERRORLEVEL% EQU 15 echo OKCOPY + FAIL + MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 14 echo FAIL + MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 13 echo OKCOPY + FAIL + MISMATCHES & goto error
		IF %ERRORLEVEL% EQU 12 echo FAIL + MISMATCHES& goto error
		IF %ERRORLEVEL% EQU 11 echo OKCOPY + FAIL + XTRA & goto error
		IF %ERRORLEVEL% EQU 10 echo FAIL + XTRA & goto error
		IF %ERRORLEVEL% EQU 9 echo OKCOPY + FAIL & goto error
		IF %ERRORLEVEL% EQU 8 echo FAIL & goto error
		IF %ERRORLEVEL% EQU 7 echo OKCOPY + MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 6 echo MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 5 echo OKCOPY + MISMATCHES & goto error
		IF %ERRORLEVEL% EQU 4 echo MISMATCHES & goto error
		IF %ERRORLEVEL% EQU 3 echo OKCOPY + XTRA
		IF %ERRORLEVEL% EQU 2 echo XTRA
		IF %ERRORLEVEL% EQU 1 echo OKCOPY
		IF %ERRORLEVEL% EQU 0 echo No Change
	)
)

:: 4. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_TEMP%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
  IF !ERRORLEVEL! NEQ 0 goto error
)

IF !ERRORLEVEL! NEQ 0 goto error

:: 4. Copy templates-update webjob
SET WEBJOB_PATH=%HOME%\site\wwwroot\App_Data\jobs\triggered\templates-update
IF NOT EXIST "%WEBJOB_PATH%" (
  mkdir "%WEBJOB_PATH%"
)

IF EXIST %WEBJOB_PATH%\templates-update.cmd (
    del %WEBJOB_PATH%\templates-update.cmd
)

copy "%DEPLOYMENT_SOURCE%\WebJobs\templates-update\templates-update.ps1" "%WEBJOB_PATH%"
copy "%DEPLOYMENT_SOURCE%\WebJobs\templates-update\settings.job" "%WEBJOB_PATH%"

:: 5. update build.txt
call :ExecuteCmd echo %SCM_COMMIT_ID% > %DEPLOYMENT_TARGET%\build.txt
IF !ERRORLEVEL! NEQ 0 (
  call :ExecuteCmd echo %SCM_COMMIT_ID% > %DEPLOYMENT_TARGET%\build.txt
  IF !ERRORLEVEL! NEQ 0 goto error
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
goto end

:: Execute command routine that will echo out when error
:ExecuteCmd
setlocal
set _CMD_=%*
call %_CMD_%
if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_%
exit /b %ERRORLEVEL%

:error
endlocal
echo An error has occurred during web site deployment.
call :exitSetErrorLevel
call :exitFromFunction 2>nul

:exitSetErrorLevel
exit /b 1

:exitFromFunction
()

:end
endlocal
echo Finished successfully.

@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off

:: ----------------------
:: KUDU Deployment Script
:: Version: 1.0.6
:: ----------------------

:: Prerequisites
:: -------------

:: Verify node.js installed
where node 2>nul >nul
IF %ERRORLEVEL% NEQ 0 (
  echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment.
  goto error
)

:: Setup
:: -----
:: Setup npm global path to d:\home

echo Print variables
echo dp0=%~dp0%
echo ARTIFACTS=%ARTIFACTS%
echo DEPLOYMENT_SOURCE=%DEPLOYMENT_SOURCE%
echo DEPLOYMENT_TARGET=%DEPLOYMENT_TARGET%
echo DEPLOYMENT_TARGET_ANGULAR=%DEPLOYMENT_TARGET_ANGULAR%
echo NEXT_MANIFEST_PATH=%NEXT_MANIFEST_PATH%
echo PREVIOUS_MANIFEST_PATH=%PREVIOUS_MANIFEST_PATH%
echo DEPLOYMENT_TEMP=%DEPLOYMENT_TEMP%
echo IN_PLACE_DEPLOYMENT=%IN_PLACE_DEPLOYMENT%
echo ANGUALR_CLI=%ANGUALR_CLI%

setlocal enabledelayedexpansion

SET ARTIFACTS=%~dp0%..\artifacts

IF NOT DEFINED DEPLOYMENT_SOURCE (
	SET DEPLOYMENT_SOURCE=%~dp0%.
	echo SET DEPLOYMENT_SOURCE
)

IF NOT DEFINED DEPLOYMENT_TARGET (
  SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot
)

IF NOT DEFINED NEXT_MANIFEST_PATH (
  SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest

  IF NOT DEFINED PREVIOUS_MANIFEST_PATH (
    SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest
  )
)

IF NOT DEFINED NEXT_CLIENT_MANIFEST_PATH (
  SET NEXT_CLIENT_MANIFEST_PATH=%ARTIFACTS%\client-manifest

  IF NOT EXIST "%NEXT_CLIENT_MANIFEST_PATH%" (MKDIR "%NEXT_CLIENT_MANIFEST_PATH%")

  IF NOT DEFINED PREVIOUS_CLIENT_MANIFEST_PATH (
    SET PREVIOUS_CLIENT_MANIFEST_PATH=%ARTIFACTS%\client-manifest
  )

  IF NOT EXIST "%PREVIOUS_CLIENT_MANIFEST_PATH%" (MKDIR "%PREVIOUS_CLIENT_MANIFEST_PATH%")
)

IF NOT EXIST "%HOME%\tools" (MKDIR "%HOME%\tools")

SET PATH=%PATH%;%HOME%\tools

call npm config set prefix "%HOME%\tools"
IF !ERRORLEVEL! NEQ 0 goto error

IF NOT DEFINED KUDU_SYNC_CMD (
  :: Install kudu sync
  echo Installing Kudu Sync
  call npm install kudusync -g --silent
  IF !ERRORLEVEL! NEQ 0 goto error

  :: Locally just running "kuduSync" would also work
  SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd
)

IF NOT DEFINED ANGUALR_CLI (
  :: Install angular-cli
  echo Installing angular-cli
  call npm install -g angular-cli@1.0.0-beta.19-3

  IF !ERRORLEVEL! NEQ 0 goto error

  SET ANGUALR_CLI=true
)

IF NOT DEFINED DEPLOYMENT_TEMP (
  SET DEPLOYMENT_TEMP=%temp%\___deployTemp%random%
  SET CLEAN_LOCAL_DEPLOYMENT_TEMP=true
)

IF DEFINED CLEAN_LOCAL_DEPLOYMENT_TEMP (
  IF EXIST "%DEPLOYMENT_TEMP%" rd /s /q "%DEPLOYMENT_TEMP%"
  mkdir "%DEPLOYMENT_TEMP%"
)

IF DEFINED MSBUILD_PATH goto MsbuildPathDefined
SET MSBUILD_PATH=%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe
:MsbuildPathDefined

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------

echo Print variables
echo dp0=%~dp0%
echo ARTIFACTS=%ARTIFACTS%
echo DEPLOYMENT_SOURCE=%DEPLOYMENT_SOURCE%
echo DEPLOYMENT_TARGET=%DEPLOYMENT_TARGET%
echo DEPLOYMENT_TARGET_ANGULAR=%DEPLOYMENT_TARGET_ANGULAR%
echo NEXT_MANIFEST_PATH=%NEXT_MANIFEST_PATH%
echo PREVIOUS_MANIFEST_PATH=%PREVIOUS_MANIFEST_PATH%
echo DEPLOYMENT_TEMP=%DEPLOYMENT_TEMP%
echo IN_PLACE_DEPLOYMENT=%IN_PLACE_DEPLOYMENT%
echo ANGUALR_CLI=%ANGUALR_CLI%

echo Handling backend WebApi project.
echo Restore NuGet packages
IF /I "AzureFunctions.sln" NEQ "" (
  call :ExecuteCmd nuget restore "%DEPLOYMENT_SOURCE%\AzureFunctions.sln"
  IF !ERRORLEVEL! NEQ 0 goto error
)

:: 1. Build backend WebApi to the temporary path
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  echo "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\AzureFunctions\AzureFunctions.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="%DEPLOYMENT_TEMP%";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false  /p:DeleteExistingFiles=False /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
  call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\AzureFunctions\AzureFunctions.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="%DEPLOYMENT_TEMP%";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false  /p:DeleteExistingFiles=False /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
) ELSE (
  call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\AzureFunctions\AzureFunctions.csproj" /nologo /verbosity:m /t:Build /p:AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false  /p:DeleteExistingFiles=False /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
)

echo Handling frontend Angular2 project.
:: 2. Bundle frontend angular2 app to the temporary path
IF EXIST "%DEPLOYMENT_SOURCE%\AzureFunctions.AngularClient\package.json" (

	IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
	echo ROBOCOPY "%DEPLOYMENT_SOURCE%\AzureFunctions.AngularClient" "%ARTIFACTS%\AzureFunctions.AngularClient" /E /IS
		call :ExecuteCmd ROBOCOPY "%DEPLOYMENT_SOURCE%\AzureFunctions.AngularClient" "%ARTIFACTS%\AzureFunctions.AngularClient" /E /IS
		:: http://ss64.com/nt/robocopy-exit.html
		IF %ERRORLEVEL% EQU 16 echo ***FATAL ERROR*** & goto error
		IF %ERRORLEVEL% EQU 15 echo OKCOPY + FAIL + MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 14 echo FAIL + MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 13 echo OKCOPY + FAIL + MISMATCHES & goto error
		IF %ERRORLEVEL% EQU 12 echo FAIL + MISMATCHES& goto error
		IF %ERRORLEVEL% EQU 11 echo OKCOPY + FAIL + XTRA & goto error
		IF %ERRORLEVEL% EQU 10 echo FAIL + XTRA & goto error
		IF %ERRORLEVEL% EQU 9 echo OKCOPY + FAIL & goto error
		IF %ERRORLEVEL% EQU 8 echo FAIL & goto error
		IF %ERRORLEVEL% EQU 7 echo OKCOPY + MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 6 echo MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 5 echo OKCOPY + MISMATCHES & goto error
		IF %ERRORLEVEL% EQU 4 echo MISMATCHES & goto error
		IF %ERRORLEVEL% EQU 3 echo OKCOPY + XTRA
		IF %ERRORLEVEL% EQU 2 echo XTRA
		IF %ERRORLEVEL% EQU 1 echo OKCOPY
		IF %ERRORLEVEL% EQU 0 echo No Change
	)

	pushd "%ARTIFACTS%\AzureFunctions.AngularClient"
	echo Restore npm packages
	call :ExecuteCmd npm install
	IF !ERRORLEVEL! NEQ 0 (
		call :ExecuteCmd npm install
		IF !ERRORLEVEL! NEQ 0 goto error
	)
	echo Bundle angular2 app
	call :ExecuteCmd ng build --prod --environment=prod --output-path="%ARTIFACTS%\AzureFunctions.AngularClient\dist"
	IF !ERRORLEVEL! NEQ 0 (
		call :ExecuteCmd ng build --prod --environment=prod --output-path="%ARTIFACTS%\AzureFunctions.AngularClient\dist"
		IF !ERRORLEVEL! NEQ 0 goto error
	)

	pushd "%ARTIFACTS%\AzureFunctions.AngularClient\dist"
		mv main.*.bundle.js main.bundle.js
		mv scripts.*.bundle.js scripts.bundle.js
		mv styles.*.bundle.js styles.bundle.js
	popd

	echo Copy angular output to the temporary path
	IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
		echo ROBOCOPY "%ARTIFACTS%\AzureFunctions.AngularClient\dist" "%DEPLOYMENT_TEMP%" /E /IS
		call :ExecuteCmd ROBOCOPY "%ARTIFACTS%\AzureFunctions.AngularClient\dist" "%DEPLOYMENT_TEMP%" /E /IS
		:: http://ss64.com/nt/robocopy-exit.html
		IF %ERRORLEVEL% EQU 16 echo ***FATAL ERROR*** & goto error
		IF %ERRORLEVEL% EQU 15 echo OKCOPY + FAIL + MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 14 echo FAIL + MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 13 echo OKCOPY + FAIL + MISMATCHES & goto error
		IF %ERRORLEVEL% EQU 12 echo FAIL + MISMATCHES& goto error
		IF %ERRORLEVEL% EQU 11 echo OKCOPY + FAIL + XTRA & goto error
		IF %ERRORLEVEL% EQU 10 echo FAIL + XTRA & goto error
		IF %ERRORLEVEL% EQU 9 echo OKCOPY + FAIL & goto error
		IF %ERRORLEVEL% EQU 8 echo FAIL & goto error
		IF %ERRORLEVEL% EQU 7 echo OKCOPY + MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 6 echo MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 5 echo OKCOPY + MISMATCHES & goto error
		IF %ERRORLEVEL% EQU 4 echo MISMATCHES & goto error
		IF %ERRORLEVEL% EQU 3 echo OKCOPY + XTRA
		IF %ERRORLEVEL% EQU 2 echo XTRA
		IF %ERRORLEVEL% EQU 1 echo OKCOPY
		IF %ERRORLEVEL% EQU 0 echo No Change

		IF EXIST "%ARTIFACTS%\AzureFunctions.AngularClient\node_modules\swagger-editor" (
			echo Copy Swagger Editor to output
			echo ROBOCOPY "%ARTIFACTS%\AzureFunctions.AngularClient\node_modules\swagger-editor" "%DEPLOYMENT_TEMP%\node_modules\swagger-editor" /E /IS
			call :ExecuteCmd ROBOCOPY "%ARTIFACTS%\AzureFunctions.AngularClient\node_modules\swagger-editor" "%DEPLOYMENT_TEMP%\node_modules\swagger-editor" /E /IS
			:: http://ss64.com/nt/robocopy-exit.html
			IF %ERRORLEVEL% EQU 16 echo ***FATAL ERROR*** & goto error
			IF %ERRORLEVEL% EQU 15 echo OKCOPY + FAIL + MISMATCHES + XTRA & goto error
			IF %ERRORLEVEL% EQU 14 echo FAIL + MISMATCHES + XTRA & goto error
			IF %ERRORLEVEL% EQU 13 echo OKCOPY + FAIL + MISMATCHES & goto error
			IF %ERRORLEVEL% EQU 12 echo FAIL + MISMATCHES& goto error
			IF %ERRORLEVEL% EQU 11 echo OKCOPY + FAIL + XTRA & goto error
			IF %ERRORLEVEL% EQU 10 echo FAIL + XTRA & goto error
			IF %ERRORLEVEL% EQU 9 echo OKCOPY + FAIL & goto error
			IF %ERRORLEVEL% EQU 8 echo FAIL & goto error
			IF %ERRORLEVEL% EQU 7 echo OKCOPY + MISMATCHES + XTRA & goto error
			IF %ERRORLEVEL% EQU 6 echo MISMATCHES + XTRA & goto error
			IF %ERRORLEVEL% EQU 5 echo OKCOPY + MISMATCHES & goto error
			IF %ERRORLEVEL% EQU 4 echo MISMATCHES & goto error
			IF %ERRORLEVEL% EQU 3 echo OKCOPY + XTRA
			IF %ERRORLEVEL% EQU 2 echo XTRA
			IF %ERRORLEVEL% EQU 1 echo OKCOPY
			IF %ERRORLEVEL% EQU 0 echo No Change
		)
	)
)

:: 4. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_TEMP%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
  IF !ERRORLEVEL! NEQ 0 goto error
)

IF !ERRORLEVEL! NEQ 0 goto error

:: 4. Copy templates-update webjob
SET WEBJOB_PATH=%HOME%\site\wwwroot\App_Data\jobs\triggered\templates-update
IF NOT EXIST "%WEBJOB_PATH%" (
  mkdir "%WEBJOB_PATH%"
)

IF EXIST %WEBJOB_PATH%\templates-update.cmd (
    del %WEBJOB_PATH%\templates-update.cmd
)

copy "%DEPLOYMENT_SOURCE%\WebJobs\templates-update\templates-update.ps1" "%WEBJOB_PATH%"
copy "%DEPLOYMENT_SOURCE%\WebJobs\templates-update\settings.job" "%WEBJOB_PATH%"

:: 5. update build.txt
call :ExecuteCmd echo %SCM_COMMIT_ID% > %DEPLOYMENT_TARGET%\build.txt
IF !ERRORLEVEL! NEQ 0 (
  call :ExecuteCmd echo %SCM_COMMIT_ID% > %DEPLOYMENT_TARGET%\build.txt
  IF !ERRORLEVEL! NEQ 0 goto error
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
goto end

:: Execute command routine that will echo out when error
:ExecuteCmd
setlocal
set _CMD_=%*
call %_CMD_%
if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_%
exit /b %ERRORLEVEL%

:error
endlocal
echo An error has occurred during web site deployment.
call :exitSetErrorLevel
call :exitFromFunction 2>nul

:exitSetErrorLevel
exit /b 1

:exitFromFunction
()

:end
endlocal
echo Finished successfully.

Copy swagger-editor to the output folder


@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off
@echo Started: %date% %time%

:: ----------------------
:: KUDU Deployment Script
:: Version: 1.0.12
:: ----------------------

:: Prerequisites
:: -------------

:: Verify node.js installed
where node 2>nul >nul
IF %ERRORLEVEL% NEQ 0 (
  echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment.
  goto error
)

:: Setup
:: -----

setlocal enabledelayedexpansion

SET ARTIFACTS=%~dp0%..\artifacts

IF NOT DEFINED DEPLOYMENT_SOURCE (
  SET DEPLOYMENT_SOURCE=%~dp0%.
)
echo "Deployment Source: %DEPLOYMENT_SOURCE%"

IF NOT DEFINED DEPLOYMENT_DIST (
    SET DEPLOYMENT_DIST=%DEPLOYMENT_SOURCE%\dist
) ELSE (
    ECHO "Deployement Dist already set"
)
echo "Deployment Dist: %DEPLOYMENT_DIST%"

IF NOT DEFINED DEPLOYMENT_TARGET (
  SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot
)
echo "Deployment Target: %DEPLOYMENT_TARGET%"

IF NOT DEFINED NEXT_MANIFEST_PATH (
  SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest

  IF NOT DEFINED PREVIOUS_MANIFEST_PATH (
    SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest
  )
)

IF NOT DEFINED KUDU_SYNC_CMD (
  :: Install kudu sync
  echo Installing Kudu Sync
  call npm install kudusync -g --silent
  IF !ERRORLEVEL! NEQ 0 goto error

  :: Locally just running "kuduSync" would also work
  SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd
)

for /F "tokens=5 delims=.\" %%a in ("%PREVIOUS_MANIFEST_PATH%") do SET PREVIOUS_SCM_COMMIT_ID=%%a

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Pre-Deployment
:: ----------
@echo "Initiating Pre-Deployment: %date% %time%"

for /F %%f in ('git.exe diff --name-only %PREVIOUS_SCM_COMMIT_ID% %SCM_COMMIT_ID% ^| grep package.json') do (
    SET PACKAGEJSON=%%~f
    echo %PACKAGEJSON%
    echo %%f
    echo %%~f
    echo "NPM Install: %DEPLOYMENT_SOURCE%\%PACKAGEJSON:~-12%"
    pushd "%DEPLOYMENT_SOURCE%\%PACKAGEJSON:~-12%"
    npm install --production --progress=false --cache-min=432000
    npm install --save json-loader --progress=false --cache-min=432000
    IF !ERRORLEVEL! NEQ 0 goto error
    popd
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------

@echo "Initiating Deployment: %date% %time%"

:: 1. Build Script
node .deploy/deploy.js

:: 2. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_DIST%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
  IF !ERRORLEVEL! NEQ 0 goto error
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
goto end

:: Execute command routine that will echo out when error
:ExecuteCmd
setlocal
set _CMD_=%*
call %_CMD_%
if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_%
exit /b %ERRORLEVEL%

:error
endlocal
echo An error has occurred during web site deployment.
call :exitSetErrorLevel
call :exitFromFunction 2>nul

:exitSetErrorLevel
exit /b 1

:exitFromFunction
()

:end
endlocal
echo Finished successfully.

@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off
@echo Started: %date% %time%

:: ----------------------
:: KUDU Deployment Script
:: Version: 1.0.12
:: ----------------------

:: Prerequisites
:: -------------

:: Verify node.js installed
where node 2>nul >nul
IF %ERRORLEVEL% NEQ 0 (
  echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment.
  goto error
)

:: Setup
:: -----

setlocal enabledelayedexpansion

SET ARTIFACTS=%~dp0%..\artifacts

IF NOT DEFINED DEPLOYMENT_SOURCE (
  SET DEPLOYMENT_SOURCE=%~dp0%.
)
echo "Deployment Source: %DEPLOYMENT_SOURCE%"

IF NOT DEFINED DEPLOYMENT_DIST (
    SET DEPLOYMENT_DIST=%DEPLOYMENT_SOURCE%\dist
) ELSE (
    ECHO "Deployement Dist already set"
)
echo "Deployment Dist: %DEPLOYMENT_DIST%"

IF NOT DEFINED DEPLOYMENT_TARGET (
  SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot
)
echo "Deployment Target: %DEPLOYMENT_TARGET%"

IF NOT DEFINED NEXT_MANIFEST_PATH (
  SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest

  IF NOT DEFINED PREVIOUS_MANIFEST_PATH (
    SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest
  )
)

IF NOT DEFINED KUDU_SYNC_CMD (
  :: Install kudu sync
  echo Installing Kudu Sync
  call npm install kudusync -g --silent
  IF !ERRORLEVEL! NEQ 0 goto error

  :: Locally just running "kuduSync" would also work
  SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd
)

for /F "tokens=5 delims=.\" %%a in ("%PREVIOUS_MANIFEST_PATH%") do SET PREVIOUS_SCM_COMMIT_ID=%%a

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Pre-Deployment
:: ----------
@echo "Initiating Pre-Deployment: %date% %time%"

for /F %%f in ('git.exe diff --name-only %PREVIOUS_SCM_COMMIT_ID% %SCM_COMMIT_ID% ^| grep package.json') do (
    SET PACKAGEJSON=%%~f
    echo !PACKAGEJSON!
    echo "NPM Install: %DEPLOYMENT_SOURCE%\!PACKAGEJSON:~-12!"
    pushd "%DEPLOYMENT_SOURCE%\!PACKAGEJSON:~-12!"
    npm install --production --progress=false --cache-min=432000
    npm install --save json-loader --progress=false --cache-min=432000
    IF !ERRORLEVEL! NEQ 0 goto error
    popd
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------

@echo "Initiating Deployment: %date% %time%"

:: 1. Build Script
node .deploy/deploy.js

:: 2. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_DIST%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
  IF !ERRORLEVEL! NEQ 0 goto error
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
goto end

:: Execute command routine that will echo out when error
:ExecuteCmd
setlocal
set _CMD_=%*
call %_CMD_%
if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_%
exit /b %ERRORLEVEL%

:error
endlocal
echo An error has occurred during web site deployment.
call :exitSetErrorLevel
call :exitFromFunction 2>nul

:exitSetErrorLevel
exit /b 1

:exitFromFunction
()

:end
endlocal
echo Finished successfully.

Build Master:2017-02-28T18:53:07.561Z

Build Master:2017-02-28T18:53:07.561Z


java^
 -Xms64m^
 -Xmx2048m^
 -XX:CompileCommand=exclude,javax/swing/text/GlyphView,getBreakSpot^
 -XX:-OmitStackTraceInFastThrow^
 -jar sw.jar

add exclude GlyphView,getBreakSpot argument


set OUTPUT=src\artifacts\rbin

call rmdir /S /Q ".\src\artifacts"

call dotnet --info

call dotnet restore --packages .\src\packages

call dotnet build src\Commons.Utils -c Release --no-dependencies -o "%OUTPUT%\net40" -f net40 --no-incremental
call dotnet build src\Commons.Collections -c Release --no-dependencies -o "%OUTPUT%\net40" -f net40 --no-incremental
call dotnet build src\Commons.Json -c Release --no-dependencies -o "%OUTPUT%\net40" -f net40 --no-incremental
call dotnet build src\Commons.Pool -c Release --no-dependencies -o "%OUTPUT%\net40" -f net40 --no-incremental
call dotnet build src\Test.Commons -c Release --no-dependencies -o "%OUTPUT%\net40" -f net40 --no-incremental

call dotnet build src\Commons.Utils -c Release --no-dependencies -o "%OUTPUT%\net45" -f net45 --no-incremental
call dotnet build src\Commons.Collections -c Release --no-dependencies -o "%OUTPUT%\net45" -f net45 --no-incremental
call dotnet build src\Commons.Json -c Release --no-dependencies -o "%OUTPUT%\net45" -f net45 --no-incremental
call dotnet build src\Commons.Pool -c Release --no-dependencies -o "%OUTPUT%\net45" -f net45 --no-incremental
call dotnet build src\Test.Commons -c Release --no-dependencies -o "%OUTPUT%\net45" -f net45 --no-incremental

call dotnet build src\Commons.Utils -c Release --no-dependencies -o "%OUTPUT%\netstandard1.3" -f netstandard1.3 --no-incremental
call dotnet build src\Commons.Collections -c Release --no-dependencies -o "%OUTPUT%\netstandard1.3" -f netstandard1.3 --no-incremental
call dotnet build src\Commons.Json -c Release --no-dependencies -o "%OUTPUT%\netstandard1.3" -f netstandard1.3 --no-incremental
call dotnet build src\Commons.Pool -c Release --no-dependencies -o "%OUTPUT%\netstandard1.3" -f netstandard1.3 --no-incremental

call dotnet build src\Test.Commons -c Release --no-dependencies -o "%OUTPUT%\netcoreapp1.0" -f netcoreapp1.0 --no-incremental

call pushd %OUTPUT%\netcoreapp1.0
call dotnet test ..\..\..\Test.Commons -o .\ --no-build -f netcoreapp1.0 -parallel none
call popd

call ".\src\packages\xunit.runner.console\2.1.0\tools\xunit.console.exe" %OUTPUT%\net40\Test.Commons.dll -parallel none
call ".\src\packages\xunit.runner.console\2.1.0\tools\xunit.console.exe" %OUTPUT%\net45\Test.Commons.dll -parallel none

.\src\.nuget\nuget pack Commons.nuspec -outputdirectory %OUTPUT%
.\src\.nuget\nuget pack Commons.Json.nuspec -outputdirectory %OUTPUT%
.\src\.nuget\nuget pack Commons.Pool.nuspec -outputdirectory %OUTPUT%

set OUTPUT=src\artifacts\rbin

call rmdir /S /Q ".\src\artifacts"

call dotnet --info

call dotnet restore

call dotnet build src\Commons.Utils -c Release --no-dependencies -o "%OUTPUT%\net40" -f net40 --no-incremental
call dotnet build src\Commons.Collections -c Release --no-dependencies -o "%OUTPUT%\net40" -f net40 --no-incremental
call dotnet build src\Commons.Json -c Release --no-dependencies -o "%OUTPUT%\net40" -f net40 --no-incremental
call dotnet build src\Commons.Pool -c Release --no-dependencies -o "%OUTPUT%\net40" -f net40 --no-incremental
call dotnet build src\Test.Commons -c Release --no-dependencies -o "%OUTPUT%\net40" -f net40 --no-incremental

call dotnet build src\Commons.Utils -c Release --no-dependencies -o "%OUTPUT%\net45" -f net45 --no-incremental
call dotnet build src\Commons.Collections -c Release --no-dependencies -o "%OUTPUT%\net45" -f net45 --no-incremental
call dotnet build src\Commons.Json -c Release --no-dependencies -o "%OUTPUT%\net45" -f net45 --no-incremental
call dotnet build src\Commons.Pool -c Release --no-dependencies -o "%OUTPUT%\net45" -f net45 --no-incremental
call dotnet build src\Test.Commons -c Release --no-dependencies -o "%OUTPUT%\net45" -f net45 --no-incremental

call dotnet build src\Commons.Utils -c Release --no-dependencies -o "%OUTPUT%\netstandard1.3" -f netstandard1.3 --no-incremental
call dotnet build src\Commons.Collections -c Release --no-dependencies -o "%OUTPUT%\netstandard1.3" -f netstandard1.3 --no-incremental
call dotnet build src\Commons.Json -c Release --no-dependencies -o "%OUTPUT%\netstandard1.3" -f netstandard1.3 --no-incremental
call dotnet build src\Commons.Pool -c Release --no-dependencies -o "%OUTPUT%\netstandard1.3" -f netstandard1.3 --no-incremental

call dotnet build src\Test.Commons -c Release --no-dependencies -o "%OUTPUT%\netcoreapp1.0" -f netcoreapp1.0 --no-incremental

call pushd %OUTPUT%\netcoreapp1.0
call dotnet test ..\..\..\Test.Commons -o .\ --no-build -f netcoreapp1.0 -parallel none
call popd

call "%USERPROFILE%\.nuget\packages\xunit.runner.console\2.1.0\tools\xunit.console.exe" %OUTPUT%\net40\Test.Commons.dll -parallel none
call "%USERPROFILE%\.nuget\packages\xunit.runner.console\2.1.0\tools\xunit.console.exe" %OUTPUT%\net45\Test.Commons.dll -parallel none

.\src\.nuget\nuget pack Commons.nuspec -outputdirectory %OUTPUT%
.\src\.nuget\nuget pack Commons.Json.nuspec -outputdirectory %OUTPUT%
.\src\.nuget\nuget pack Commons.Pool.nuspec -outputdirectory %OUTPUT%

revert previous

revert previous


SET GOPATH=%CD%\gopath
SET GATSPATH=%GOPATH%\src\github.com\cloudfoundry\cli-acceptance-tests

SET PATH=C:\Go\bin;%PATH%
SET PATH=C:\Program Files\Git\cmd\;%PATH%
SET PATH=%GOPATH%\bin;%PATH%
SET PATH=C:\Program Files\7-Zip;%PATH%
SET PATH=C:\Program Files\cURL\bin;%PATH%
SET PATH=%CD%;%PATH%

SET /p DOMAIN=<%CD%\bosh-lite-lock\name
call %CD%\cli-ci\ci\tasks\create-cats-config.bat
SET CONFIG=%CD%\config.json

pushd %CD%\cf-cli-binaries
	7z x cf-cli-binaries.tgz
	7z x cf-cli-binaries.tar
	MOVE %CD%\cf-cli_winx64.exe ..\cf.exe
popd

go get -v github.com/onsi/ginkgo/ginkgo

cd %GATSPATH%
ginkgo.exe -r -nodes=4 -slowSpecThreshold=120 -randomizeSuites -skipPackage application ./gats
ginkgo.exe -r -nodes=4 -slowSpecThreshold=120 -randomizeSuites ./gats/application

SET GOPATH=%CD%\gopath
SET GATSPATH=%GOPATH%\src\github.com\cloudfoundry\cli-acceptance-tests

SET PATH=C:\Go\bin;%PATH%
SET PATH=C:\Program Files\Git\cmd\;%PATH%
SET PATH=%GOPATH%\bin;%PATH%
SET PATH=C:\Program Files\GnuWin32\bin;%PATH%
SET PATH=C:\Program Files\cURL\bin;%PATH%
SET PATH=%CD%;%PATH%

SET /p DOMAIN=<%CD%\bosh-lite-lock\name
call %CD%\cli-ci\ci\tasks\create-cats-config.bat
SET CONFIG=%CD%\config.json

pushd %CD%\cf-cli-binaries
	gzip -d cf-cli-binaries.tgz
	tar -xvf cf-cli-binaries.tar
	MOVE %CD%\cf-cli_winx64.exe ..\cf.exe
popd

go get -v github.com/onsi/ginkgo/ginkgo

cd %GATSPATH%
ginkgo.exe -r -nodes=4 -slowSpecThreshold=120 -randomizeSuites -skipPackage application ./gats
ginkgo.exe -r -nodes=4 -slowSpecThreshold=120 -randomizeSuites ./gats/application

Revert "switching to 7z as well, sourceforge still broke"

This reverts commit 9b2c32b64adb595d5c2e19ca7d0abf421eacc097.


@echo off
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\E00E0804" /va /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\E00E0804" /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Keyboard Layouts\E00E0804" /va /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Keyboard Layouts\E00E0804" /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Keyboard Layouts\E00E0804" /va /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Keyboard Layouts\E00E0804" /f >nul 2>nul
reg delete "HKCR\CLSID\{F3BA9074-6C7E-11D4-97FA-0080C882687E}" /va /f >nul 2>nul
reg delete "HKCR\CLSID\{F3BA9074-6C7E-11D4-97FA-0080C882687E}" /f >nul 2>nul
reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\MSSCIPY" /va /f >nul 2>nul
reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\MSSCIPY" /f >nul 2>nul
reg delete "HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\MSSCIPY" /va /f >nul 2>nul
reg delete "HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\MSSCIPY" /f >nul 2>nul
reg delete "HKEY_USERS\S-1-5-19\Software\Microsoft\Windows\CurrentVersion\MSSCIPY" /va /f >nul 2>nul
reg delete "HKEY_USERS\S-1-5-19\Software\Microsoft\Windows\CurrentVersion\MSSCIPY" /f >nul 2>nul
reg delete "HKEY_USERS\S-1-5-20\Software\Microsoft\Windows\CurrentVersion\MSSCIPY" /va /f >nul 2>nul
reg delete "HKEY_USERS\S-1-5-20\Software\Microsoft\Windows\CurrentVersion\MSSCIPY" /f >nul 2>nul

reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\E0010804" /va /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\E0010804" /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Keyboard Layouts\E0010804" /va /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Keyboard Layouts\E0010804" /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Keyboard Layouts\E0010804" /va /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Keyboard Layouts\E0010804" /f >nul 2>nul

reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\E0020804" /va /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\E0020804" /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Keyboard Layouts\E0020804" /va /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Keyboard Layouts\E0020804" /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Keyboard Layouts\E0020804" /va /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Keyboard Layouts\E0020804" /f >nul 2>nul

reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\E0030804" /va /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\E0030804" /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Keyboard Layouts\E0030804" /va /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Keyboard Layouts\E0030804" /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Keyboard Layouts\E0030804" /va /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Keyboard Layouts\E0030804" /f >nul 2>nul

reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\E0040804" /va /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\E0040804" /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Keyboard Layouts\E0040804" /va /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Keyboard Layouts\E0040804" /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Keyboard Layouts\E0040804" /va /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Keyboard Layouts\E0040804" /f >nul 2>nul

reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\E0050804" /va /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\E0050804" /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Keyboard Layouts\E0050804" /va /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Keyboard Layouts\E0050804" /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Keyboard Layouts\E0050804" /va /f >nul 2>nul
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Keyboard Layouts\E0050804" /f >nul 2>nul

msg "%username%" "已删除所有中文输入法。"

add delime;

add delime;


@echo ==== STARTING ====
@echo.

@IF EXIST .\dist\ (
    @echo ^=^=^> Remove dist folder:
    @RMDIR /S .\dist
)
@REM ) ELSE (
@REM )

@echo.
@echo ^=^=^> Building app:
@call npm run build

@echo.
@echo ^=^=^> Copying not scanned files:
XCOPY /v .\CNAME .\dist
XCOPY /v .\LICENSE .\dist
XCOPY /v .\README.md .\dist
XCOPY /v .\Makefile .\dist
XCOPY /v .\deploy.bat .\dist

@echo.
@echo ^=^=^> Checkout master branch:
@call git checkout master

@echo.
@echo ^=^=^> Apply dist and clean unwanted files and folders:
XCOPY /v /h /y .\dist\* .\
@RMDIR /S .\dist

@echo ==== STARTING ====
@echo.

@IF EXIST .\dist\ (
    @echo ^=^=^> Remove dist folder:
    @RMDIR /S .\dist
)
@REM ) ELSE (
@REM )

@echo.
@echo ^=^=^> Building app:
@call npm run build

@echo.
@echo ^=^=^> Copying not scanned files:
XCOPY /v .\CNAME .\dist
XCOPY /v .\LICENSE .\dist
XCOPY /v .\README.md .\dist
XCOPY /v .\Makefile .\dist
XCOPY /v .\deploy.bat .\dist

@echo.
@echo ^=^=^> Checkout master branch:
@call git checkout master

@echo.
@echo ^=^=^> Apply dist and clean unwanted files and folders:
XCOPY /s /v /h /y .\dist\* .\
@RMDIR /S /Q .\dist

deploy batch

deploy batch


@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off

:: ----------------------
:: KUDU Deployment Script
:: Version: 1.0.7
:: ----------------------

:: Prerequisites
:: -------------

:: Verify node.js installed
where node 2>nul >nul
IF %ERRORLEVEL% NEQ 0 (
  echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment.
  goto error
)

:: Setup
:: -----

setlocal enabledelayedexpansion

SET ARTIFACTS=%~dp0%..\artifacts

IF NOT DEFINED DEPLOYMENT_SOURCE (
  SET DEPLOYMENT_SOURCE=%~dp0%.
)

IF NOT DEFINED DEPLOYMENT_TARGET (
  SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot
)

IF NOT DEFINED NEXT_MANIFEST_PATH (
  SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest

  IF NOT DEFINED PREVIOUS_MANIFEST_PATH (
    SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest
  )
)

IF NOT DEFINED KUDU_SYNC_CMD (
  :: Install kudu sync
  echo Installing Kudu Sync
  call npm install kudusync -g --silent
  IF !ERRORLEVEL! NEQ 0 goto error

  :: Locally just running "kuduSync" would also work
  SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd
)
IF NOT DEFINED DEPLOYMENT_TEMP (
  SET DEPLOYMENT_TEMP=%temp%\___deployTemp%random%
  SET CLEAN_LOCAL_DEPLOYMENT_TEMP=true
)

IF DEFINED CLEAN_LOCAL_DEPLOYMENT_TEMP (
  IF EXIST "%DEPLOYMENT_TEMP%" rd /s /q "%DEPLOYMENT_TEMP%"
  mkdir "%DEPLOYMENT_TEMP%"
)

IF DEFINED MSBUILD_PATH goto MsbuildPathDefined
SET MSBUILD_PATH=%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe
:MsbuildPathDefined
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------

echo Handling ASP.NET Core Web Application deployment.

:: 1. Restore nuget packages
echo Restoring nuget packages for all project.json projects
call :ExecuteCmd nuget.exe restore -packagesavemode nuspec
IF !ERRORLEVEL! NEQ 0 goto error

:: 2a. Build
echo Storing Git Version Info for Runtime Display
call :ExecuteCmd PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "(Get-Content AllReadyApp\Web-App\AllReady\version.json).replace('GITVERSION', (git rev-parse --short HEAD)) | Set-Content AllReadyApp\Web-App\AllReady\version.json"

echo Moving In to AllReadyApp Directory
pushd "%DEPLOYMENT_SOURCE%\AllReadyApp"

echo Building AllReady.Core Project (project.json)
call :ExecuteCmd dotnet build "%DEPLOYMENT_SOURCE%\AllReadyApp\AllReady.Core\project.json" --configuration Debug
IF !ERRORLEVEL! NEQ 0 goto error

echo Not Building AllReady Project (it gets built with publish command)

echo Building Web Jobs Project (project.json)
call :ExecuteCmd dotnet build "%DEPLOYMENT_SOURCE%\AllReadyApp\AllReady.NotificationsWebJob\project.json" --configuration Debug
IF !ERRORLEVEL! NEQ 0 goto error

:: 2b. Publish AllReady
echo Publishing Allready Project (project.json) which includes building it
call :ExecuteCmd dotnet publish "%DEPLOYMENT_SOURCE%\AllReadyApp\Web-App\AllReady" --output "%DEPLOYMENT_TEMP%" --configuration Debug
IF !ERRORLEVEL! NEQ 0 goto error

echo Moving Out of AllReadyApp Directory
popd

:: 2c. Publish WebJobs (AllReady.NotificationsWebJob)
echo Publishing AllReady.NotificationsWebJob WebJob
call :ExecuteCmd mkdir "%DEPLOYMENT_TEMP%\app_data\jobs\continuous\notificationsprocessor\"
call :ExecuteCmd xcopy /S "%DEPLOYMENT_SOURCE%\AllReadyApp\AllReady.NotificationsWebJob\bin\debug\net451" "%DEPLOYMENT_TEMP%\app_data\jobs\continuous\notificationsprocessor\"

:: 3. KuduSync
call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_TEMP%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
IF !ERRORLEVEL! NEQ 0 goto error

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
goto end

:: Execute command routine that will echo out when error
:ExecuteCmd
setlocal
set _CMD_=%*
call %_CMD_%
if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_%
exit /b %ERRORLEVEL%

:error
endlocal
echo An error has occurred during web site deployment.
call :exitSetErrorLevel
call :exitFromFunction 2>nul

:exitSetErrorLevel
exit /b 1

:exitFromFunction
()

:end
endlocal
echo Finished successfully.

@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off

:: ----------------------
:: KUDU Deployment Script
:: Version: 1.0.7
:: ----------------------

:: Prerequisites
:: -------------

:: Verify node.js installed
where node 2>nul >nul
IF %ERRORLEVEL% NEQ 0 (
  echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment.
  goto error
)

:: Setup
:: -----

setlocal enabledelayedexpansion

SET ARTIFACTS=%~dp0%..\artifacts

IF NOT DEFINED DEPLOYMENT_SOURCE (
  SET DEPLOYMENT_SOURCE=%~dp0%.
)

IF NOT DEFINED DEPLOYMENT_TARGET (
  SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot
)

IF NOT DEFINED NEXT_MANIFEST_PATH (
  SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest

  IF NOT DEFINED PREVIOUS_MANIFEST_PATH (
    SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest
  )
)

IF NOT DEFINED KUDU_SYNC_CMD (
  :: Install kudu sync
  echo Installing Kudu Sync
  call npm install kudusync -g --silent
  IF !ERRORLEVEL! NEQ 0 goto error

  :: Locally just running "kuduSync" would also work
  SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd
)
IF NOT DEFINED DEPLOYMENT_TEMP (
  SET DEPLOYMENT_TEMP=%temp%\___deployTemp%random%
  SET CLEAN_LOCAL_DEPLOYMENT_TEMP=true
)

IF DEFINED CLEAN_LOCAL_DEPLOYMENT_TEMP (
  IF EXIST "%DEPLOYMENT_TEMP%" rd /s /q "%DEPLOYMENT_TEMP%"
  mkdir "%DEPLOYMENT_TEMP%"
)

IF DEFINED MSBUILD_PATH goto MsbuildPathDefined
SET MSBUILD_PATH=%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe
:MsbuildPathDefined
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------

echo Handling ASP.NET Core Web Application deployment.

:: 1. Restore nuget packages
echo Restoring nuget packages for all project.json projects
call :ExecuteCmd nuget.exe restore -packagesavemode nuspec
IF !ERRORLEVEL! NEQ 0 goto error

:: 2a. Build
echo Storing Git Version Info for Runtime Display
call :ExecuteCmd PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "(Get-Content AllReadyApp\Web-App\AllReady\version.json).replace('GITVERSION', (git rev-parse --short HEAD)) | Set-Content AllReadyApp\Web-App\AllReady\version.json"

echo Moving In to AllReadyApp Directory
pushd "%DEPLOYMENT_SOURCE%\AllReadyApp"

echo Building AllReady.Core Project (project.json)
call :ExecuteCmd dotnet build "%DEPLOYMENT_SOURCE%\AllReadyApp\AllReady.Core\project.json" --configuration Debug
IF !ERRORLEVEL! NEQ 0 goto error

echo Not Building AllReady Project (it gets built with publish command)

echo Building Web Jobs Project (project.json)
call :ExecuteCmd dotnet build "%DEPLOYMENT_SOURCE%\AllReadyApp\AllReady.NotificationsWebJob\project.json" --configuration Debug
IF !ERRORLEVEL! NEQ 0 goto error

:: 2b. Publish AllReady
echo Publishing Allready Project (project.json) which includes building it
call :ExecuteCmd dotnet publish "%DEPLOYMENT_SOURCE%\AllReadyApp\Web-App\AllReady" --output "%DEPLOYMENT_TEMP%" --configuration Debug
copy "%DEPLOYMENT_SOURCE%\AllReadyApp\Web-App\AllReady\version.json" "%DEPLOYMENT_TEMP%\version.json" /y
IF !ERRORLEVEL! NEQ 0 goto error

echo Moving Out of AllReadyApp Directory
popd

:: 2c. Publish WebJobs (AllReady.NotificationsWebJob)
echo Publishing AllReady.NotificationsWebJob WebJob
call :ExecuteCmd mkdir "%DEPLOYMENT_TEMP%\app_data\jobs\continuous\notificationsprocessor\"
call :ExecuteCmd xcopy /S "%DEPLOYMENT_SOURCE%\AllReadyApp\AllReady.NotificationsWebJob\bin\debug\net451" "%DEPLOYMENT_TEMP%\app_data\jobs\continuous\notificationsprocessor\"

:: 3. KuduSync
call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_TEMP%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
IF !ERRORLEVEL! NEQ 0 goto error

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
goto end

:: Execute command routine that will echo out when error
:ExecuteCmd
setlocal
set _CMD_=%*
call %_CMD_%
if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_%
exit /b %ERRORLEVEL%

:error
endlocal
echo An error has occurred during web site deployment.
call :exitSetErrorLevel
call :exitFromFunction 2>nul

:exitSetErrorLevel
exit /b 1

:exitFromFunction
()

:end
endlocal
echo Finished successfully.

fix for deploy commit tag to live site

fix for deploy commit tag to live site


@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off

:: ----------------------
:: KUDU Deployment Script
:: Version: 1.0.6
:: ----------------------

:: Prerequisites
:: -------------

:: Verify node.js installed
where node 2>nul >nul
IF %ERRORLEVEL% NEQ 0 (
  echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment.
  goto error
)

:: Setup
:: -----

setlocal enabledelayedexpansion

SET ARTIFACTS=%~dp0%..\artifacts

IF NOT DEFINED DEPLOYMENT_SOURCE (
	SET DEPLOYMENT_SOURCE=%~dp0%.
	echo SET DEPLOYMENT_SOURCE
)

IF NOT DEFINED DEPLOYMENT_TARGET (
  SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot
)

IF NOT DEFINED NEXT_MANIFEST_PATH (
  SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest

  IF NOT DEFINED PREVIOUS_MANIFEST_PATH (
    SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest
  )
)

IF NOT DEFINED NEXT_CLIENT_MANIFEST_PATH (
  SET NEXT_CLIENT_MANIFEST_PATH=%ARTIFACTS%\client-manifest

  IF NOT EXIST "%NEXT_CLIENT_MANIFEST_PATH%" (MKDIR "%NEXT_CLIENT_MANIFEST_PATH%")

  IF NOT DEFINED PREVIOUS_CLIENT_MANIFEST_PATH (
    SET PREVIOUS_CLIENT_MANIFEST_PATH=%ARTIFACTS%\client-manifest
  )

  IF NOT EXIST "%PREVIOUS_CLIENT_MANIFEST_PATH%" (MKDIR "%PREVIOUS_CLIENT_MANIFEST_PATH%")
)

IF NOT DEFINED KUDU_SYNC_CMD (
  :: Install kudu sync
  echo Installing Kudu Sync
  call npm install kudusync -g --silent
  IF !ERRORLEVEL! NEQ 0 goto error

  :: Locally just running "kuduSync" would also work
  SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd
)

IF NOT DEFINED ANGUALR_CLI (
  :: Install angular-cli
  echo Installing angular-cli Sync
  call npm install -g angular-cli --silent
  IF !ERRORLEVEL! NEQ 0 goto error

  SET ANGUALR_CLI=true
)

IF NOT DEFINED DEPLOYMENT_TEMP (
  SET DEPLOYMENT_TEMP=%temp%\___deployTemp%random%
  SET CLEAN_LOCAL_DEPLOYMENT_TEMP=true
)

IF DEFINED CLEAN_LOCAL_DEPLOYMENT_TEMP (
  IF EXIST "%DEPLOYMENT_TEMP%" rd /s /q "%DEPLOYMENT_TEMP%"
  mkdir "%DEPLOYMENT_TEMP%"
)

IF DEFINED MSBUILD_PATH goto MsbuildPathDefined
SET MSBUILD_PATH=%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe
:MsbuildPathDefined

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------

echo Print variables
echo dp0=%~dp0%
echo ARTIFACTS=%ARTIFACTS%
echo DEPLOYMENT_SOURCE=%DEPLOYMENT_SOURCE%
echo DEPLOYMENT_TARGET=%DEPLOYMENT_TARGET%
echo DEPLOYMENT_TARGET_ANGULAR=%DEPLOYMENT_TARGET_ANGULAR%
echo NEXT_MANIFEST_PATH=%NEXT_MANIFEST_PATH%
echo PREVIOUS_MANIFEST_PATH=%PREVIOUS_MANIFEST_PATH%
echo DEPLOYMENT_TEMP=%DEPLOYMENT_TEMP%
echo IN_PLACE_DEPLOYMENT=%IN_PLACE_DEPLOYMENT%

echo Handling backend WebApi project.
echo Restore NuGet packages
IF /I "AzureFunctions.sln" NEQ "" (
  call :ExecuteCmd nuget restore "%DEPLOYMENT_SOURCE%\AzureFunctions.sln"
  IF !ERRORLEVEL! NEQ 0 goto error
)

:: 1. Build backend WebApi to the temporary path
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  echo "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\AzureFunctions\AzureFunctions.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="%DEPLOYMENT_TEMP%";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false  /p:DeleteExistingFiles=False /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
  call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\AzureFunctions\AzureFunctions.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="%DEPLOYMENT_TEMP%";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false  /p:DeleteExistingFiles=False /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
) ELSE (
  call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\AzureFunctions\AzureFunctions.csproj" /nologo /verbosity:m /t:Build /p:AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false  /p:DeleteExistingFiles=False /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
)

echo Handling frontend Angular2 project.
:: 2. Bundle frontend angular2 app to the temporary path
IF EXIST "%DEPLOYMENT_SOURCE%\AzureFunctions.AngularClient\package.json" (
	pushd "%DEPLOYMENT_SOURCE%\AzureFunctions.AngularClient"
	echo Restore npm packages
	call :ExecuteCmd npm install
	IF !ERRORLEVEL! NEQ 0 (
		call :ExecuteCmd npm install
		IF !ERRORLEVEL! NEQ 0 goto error
	)
	echo Bundle angular2 app
	call :ExecuteCmd ng build --environment=prod --output-path="%DEPLOYMENT_SOURCE%\AzureFunctions.AngularClient\dist"
	IF !ERRORLEVEL! NEQ 0 (
		call :ExecuteCmd ng build --environment=prod --output-path="%DEPLOYMENT_SOURCE%\AzureFunctions.AngularClient\dist"
		IF !ERRORLEVEL! NEQ 0 goto error
	)

	each Copy angular output to the temporary path
	IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
	echo ROBOCOPY "%DEPLOYMENT_SOURCE%\AzureFunctions.AngularClient\dist" "%DEPLOYMENT_TEMP%" /E /IS
		call :ExecuteCmd ROBOCOPY "%DEPLOYMENT_SOURCE%\AzureFunctions.AngularClient\dist" "%DEPLOYMENT_TEMP%" /E /IS
		:: http://ss64.com/nt/robocopy-exit.html
		IF %ERRORLEVEL% EQU 16 echo ***FATAL ERROR*** & goto error
		IF %ERRORLEVEL% EQU 15 echo OKCOPY + FAIL + MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 14 echo FAIL + MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 13 echo OKCOPY + FAIL + MISMATCHES & goto error
		IF %ERRORLEVEL% EQU 12 echo FAIL + MISMATCHES& goto error
		IF %ERRORLEVEL% EQU 11 echo OKCOPY + FAIL + XTRA & goto error
		IF %ERRORLEVEL% EQU 10 echo FAIL + XTRA & goto error
		IF %ERRORLEVEL% EQU 9 echo OKCOPY + FAIL & goto error
		IF %ERRORLEVEL% EQU 8 echo FAIL & goto error
		IF %ERRORLEVEL% EQU 7 echo OKCOPY + MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 6 echo MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 5 echo OKCOPY + MISMATCHES & goto error
		IF %ERRORLEVEL% EQU 4 echo MISMATCHES & goto error
		IF %ERRORLEVEL% EQU 3 echo OKCOPY + XTRA
		IF %ERRORLEVEL% EQU 2 echo XTRA
		IF %ERRORLEVEL% EQU 1 echo OKCOPY
		IF %ERRORLEVEL% EQU 0 echo No Change
	)
)

:: 4. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_TEMP%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
  IF !ERRORLEVEL! NEQ 0 goto error
)

IF !ERRORLEVEL! NEQ 0 goto error

:: 4. Copy templates-update webjob
SET WEBJOB_PATH=%HOME%\site\wwwroot\App_Data\jobs\triggered\templates-update
IF NOT EXIST "%WEBJOB_PATH%" (
  mkdir "%WEBJOB_PATH%"
)

IF EXIST %WEBJOB_PATH%\templates-update.cmd (
    del %WEBJOB_PATH%\templates-update.cmd
)

copy "%DEPLOYMENT_SOURCE%\WebJobs\templates-update\templates-update.ps1" "%WEBJOB_PATH%"
copy "%DEPLOYMENT_SOURCE%\WebJobs\templates-update\settings.job" "%WEBJOB_PATH%"

:: 5. update build.txt
call :ExecuteCmd echo %SCM_COMMIT_ID% > %DEPLOYMENT_TARGET%\build.txt
IF !ERRORLEVEL! NEQ 0 (
  call :ExecuteCmd echo %SCM_COMMIT_ID% > %DEPLOYMENT_TARGET%\build.txt
  IF !ERRORLEVEL! NEQ 0 goto error
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
goto end

:: Execute command routine that will echo out when error
:ExecuteCmd
setlocal
set _CMD_=%*
call %_CMD_%
if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_%
exit /b %ERRORLEVEL%

:error
endlocal
echo An error has occurred during web site deployment.
call :exitSetErrorLevel
call :exitFromFunction 2>nul

:exitSetErrorLevel
exit /b 1

:exitFromFunction
()

:end
endlocal
echo Finished successfully.

@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off

:: ----------------------
:: KUDU Deployment Script
:: Version: 1.0.6
:: ----------------------

:: Prerequisites
:: -------------

:: Verify node.js installed
where node 2>nul >nul
IF %ERRORLEVEL% NEQ 0 (
  echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment.
  goto error
)

:: Setup
:: -----

setlocal enabledelayedexpansion

SET ARTIFACTS=%~dp0%..\artifacts

IF NOT DEFINED DEPLOYMENT_SOURCE (
	SET DEPLOYMENT_SOURCE=%~dp0%.
	echo SET DEPLOYMENT_SOURCE
)

IF NOT DEFINED DEPLOYMENT_TARGET (
  SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot
)

IF NOT DEFINED NEXT_MANIFEST_PATH (
  SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest

  IF NOT DEFINED PREVIOUS_MANIFEST_PATH (
    SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest
  )
)

IF NOT DEFINED NEXT_CLIENT_MANIFEST_PATH (
  SET NEXT_CLIENT_MANIFEST_PATH=%ARTIFACTS%\client-manifest

  IF NOT EXIST "%NEXT_CLIENT_MANIFEST_PATH%" (MKDIR "%NEXT_CLIENT_MANIFEST_PATH%")

  IF NOT DEFINED PREVIOUS_CLIENT_MANIFEST_PATH (
    SET PREVIOUS_CLIENT_MANIFEST_PATH=%ARTIFACTS%\client-manifest
  )

  IF NOT EXIST "%PREVIOUS_CLIENT_MANIFEST_PATH%" (MKDIR "%PREVIOUS_CLIENT_MANIFEST_PATH%")
)

IF NOT DEFINED KUDU_SYNC_CMD (
  :: Install kudu sync
  echo Installing Kudu Sync
  call npm install kudusync -g --silent
  IF !ERRORLEVEL! NEQ 0 goto error

  :: Locally just running "kuduSync" would also work
  SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd
)

IF NOT DEFINED ANGUALR_CLI (
  :: Install angular-cli
  echo Installing angular-cli
  call npm install -g angular-cli

  IF !ERRORLEVEL! NEQ 0 goto error

  SET ANGUALR_CLI=true
)

IF NOT DEFINED DEPLOYMENT_TEMP (
  SET DEPLOYMENT_TEMP=%temp%\___deployTemp%random%
  SET CLEAN_LOCAL_DEPLOYMENT_TEMP=true
)

IF DEFINED CLEAN_LOCAL_DEPLOYMENT_TEMP (
  IF EXIST "%DEPLOYMENT_TEMP%" rd /s /q "%DEPLOYMENT_TEMP%"
  mkdir "%DEPLOYMENT_TEMP%"
)

IF DEFINED MSBUILD_PATH goto MsbuildPathDefined
SET MSBUILD_PATH=%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe
:MsbuildPathDefined

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------

echo Print variables
echo dp0=%~dp0%
echo ARTIFACTS=%ARTIFACTS%
echo DEPLOYMENT_SOURCE=%DEPLOYMENT_SOURCE%
echo DEPLOYMENT_TARGET=%DEPLOYMENT_TARGET%
echo DEPLOYMENT_TARGET_ANGULAR=%DEPLOYMENT_TARGET_ANGULAR%
echo NEXT_MANIFEST_PATH=%NEXT_MANIFEST_PATH%
echo PREVIOUS_MANIFEST_PATH=%PREVIOUS_MANIFEST_PATH%
echo DEPLOYMENT_TEMP=%DEPLOYMENT_TEMP%
echo IN_PLACE_DEPLOYMENT=%IN_PLACE_DEPLOYMENT%

echo Handling backend WebApi project.
echo Restore NuGet packages
IF /I "AzureFunctions.sln" NEQ "" (
  call :ExecuteCmd nuget restore "%DEPLOYMENT_SOURCE%\AzureFunctions.sln"
  IF !ERRORLEVEL! NEQ 0 goto error
)

:: 1. Build backend WebApi to the temporary path
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  echo "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\AzureFunctions\AzureFunctions.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="%DEPLOYMENT_TEMP%";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false  /p:DeleteExistingFiles=False /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
  call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\AzureFunctions\AzureFunctions.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="%DEPLOYMENT_TEMP%";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false  /p:DeleteExistingFiles=False /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
) ELSE (
  call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\AzureFunctions\AzureFunctions.csproj" /nologo /verbosity:m /t:Build /p:AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false  /p:DeleteExistingFiles=False /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
)

echo Handling frontend Angular2 project.
:: 2. Bundle frontend angular2 app to the temporary path
IF EXIST "%DEPLOYMENT_SOURCE%\AzureFunctions.AngularClient\package.json" (
	pushd "%DEPLOYMENT_SOURCE%\AzureFunctions.AngularClient"
	echo Restore npm packages
	call :ExecuteCmd npm install
	IF !ERRORLEVEL! NEQ 0 (
		call :ExecuteCmd npm install
		IF !ERRORLEVEL! NEQ 0 goto error
	)
	echo Bundle angular2 app
	call :ExecuteCmd ng build --environment=prod --output-path="%DEPLOYMENT_SOURCE%\AzureFunctions.AngularClient\dist"
	IF !ERRORLEVEL! NEQ 0 (
		call :ExecuteCmd ng build --environment=prod --output-path="%DEPLOYMENT_SOURCE%\AzureFunctions.AngularClient\dist"
		IF !ERRORLEVEL! NEQ 0 goto error
	)

	each Copy angular output to the temporary path
	IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
	echo ROBOCOPY "%DEPLOYMENT_SOURCE%\AzureFunctions.AngularClient\dist" "%DEPLOYMENT_TEMP%" /E /IS
		call :ExecuteCmd ROBOCOPY "%DEPLOYMENT_SOURCE%\AzureFunctions.AngularClient\dist" "%DEPLOYMENT_TEMP%" /E /IS
		:: http://ss64.com/nt/robocopy-exit.html
		IF %ERRORLEVEL% EQU 16 echo ***FATAL ERROR*** & goto error
		IF %ERRORLEVEL% EQU 15 echo OKCOPY + FAIL + MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 14 echo FAIL + MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 13 echo OKCOPY + FAIL + MISMATCHES & goto error
		IF %ERRORLEVEL% EQU 12 echo FAIL + MISMATCHES& goto error
		IF %ERRORLEVEL% EQU 11 echo OKCOPY + FAIL + XTRA & goto error
		IF %ERRORLEVEL% EQU 10 echo FAIL + XTRA & goto error
		IF %ERRORLEVEL% EQU 9 echo OKCOPY + FAIL & goto error
		IF %ERRORLEVEL% EQU 8 echo FAIL & goto error
		IF %ERRORLEVEL% EQU 7 echo OKCOPY + MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 6 echo MISMATCHES + XTRA & goto error
		IF %ERRORLEVEL% EQU 5 echo OKCOPY + MISMATCHES & goto error
		IF %ERRORLEVEL% EQU 4 echo MISMATCHES & goto error
		IF %ERRORLEVEL% EQU 3 echo OKCOPY + XTRA
		IF %ERRORLEVEL% EQU 2 echo XTRA
		IF %ERRORLEVEL% EQU 1 echo OKCOPY
		IF %ERRORLEVEL% EQU 0 echo No Change
	)
)

:: 4. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_TEMP%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
  IF !ERRORLEVEL! NEQ 0 goto error
)

IF !ERRORLEVEL! NEQ 0 goto error

:: 4. Copy templates-update webjob
SET WEBJOB_PATH=%HOME%\site\wwwroot\App_Data\jobs\triggered\templates-update
IF NOT EXIST "%WEBJOB_PATH%" (
  mkdir "%WEBJOB_PATH%"
)

IF EXIST %WEBJOB_PATH%\templates-update.cmd (
    del %WEBJOB_PATH%\templates-update.cmd
)

copy "%DEPLOYMENT_SOURCE%\WebJobs\templates-update\templates-update.ps1" "%WEBJOB_PATH%"
copy "%DEPLOYMENT_SOURCE%\WebJobs\templates-update\settings.job" "%WEBJOB_PATH%"

:: 5. update build.txt
call :ExecuteCmd echo %SCM_COMMIT_ID% > %DEPLOYMENT_TARGET%\build.txt
IF !ERRORLEVEL! NEQ 0 (
  call :ExecuteCmd echo %SCM_COMMIT_ID% > %DEPLOYMENT_TARGET%\build.txt
  IF !ERRORLEVEL! NEQ 0 goto error
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
goto end

:: Execute command routine that will echo out when error
:ExecuteCmd
setlocal
set _CMD_=%*
call %_CMD_%
if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_%
exit /b %ERRORLEVEL%

:error
endlocal
echo An error has occurred during web site deployment.
call :exitSetErrorLevel
call :exitFromFunction 2>nul

:exitSetErrorLevel
exit /b 1

:exitFromFunction
()

:end
endlocal
echo Finished successfully.

Remove silent

Remove silent


@echo off

rem Download soil moisture data
cate ds copy esacci.SOILMOISTURE.day.L3S.SSMV.multi-sensor.multi-platform.COMBINED.02-2.r1 --name SOIL_2007 --time "2007-01-01,2007-12-31" --region "72,8,85,17" --vars "sm,sm_uncertainty"

rem Download sea surface temperature data
cate ds copy esacci.SST.day.L4.SSTdepth.multi-sensor.multi-platform.OSTIA.1-1.r1 --name SST_2006_2007 --time "2006-01-01,2007-12-31" --region " -175,-10,-115,10" --vars "analysed_sst,analysis_error"

rmdir /S /Q uc06
mkdir uc06
cd uc06

rem Start interactive session by initialising an empty workspace
cate ws init

rem Open the datasets and assign to resource names
cate res open soil local.SOIL_2007
rem Doesn't work see Issue #257
cate res open sst local.SST_2006_2007

rem Perform temporal aggregation
cate res set soil_mon temporal_aggregation ds=@soil
cate res set sst_mon temporal_aggregation ds=@sst

rem Perform Long term averaging
cate res set sst_lta long_term_average ds=@sst_mon

rem Save the long term average dataset in the current directory
cate res write sst_lta sst_lta.nc

rem Perform ENSO index calculation
cate res set enso enso_nino34 ds=@sst_mon var="analysed_sst" file="sst_lta.nc"

rem Select a point of soil moisture in south of India
cate res set soil_mon_point tseries_point ds=@soil_mon point="78,12" var="sm"

rem Subset the datasets with a one month lag
cate res set soil_jannov subset_temporal ds=@soil_mon_point time_range="2007-01-01,2007-11-01"
cate res set enso_decoct subset_temporal ds=@enso time_range="2006-12-01,2007-10-01"

rem Perform correlation calculation
cate res set corr pearson_correlation_scalar ds_x=@enso_decoct ds_y=@soil_jannov var_x="ENSO N3.4 Index" var_y="sm"
cate res print corr

rem Save and close the workspace
cate ws save
cate ws close
rem Exit the interactive session
cate ws exit --yes

cd ..

@echo off

rem Download soil moisture data
cate ds copy esacci.SOILMOISTURE.day.L3S.SSMV.multi-sensor.multi-platform.COMBINED.03-2.r1 --name SOIL_2007 --time "2007-01-01,2007-12-31" --region "72,8,85,17" --vars "sm,sm_uncertainty"

rem Download sea surface temperature data
cate ds copy esacci.SST.day.L4.SSTdepth.multi-sensor.multi-platform.OSTIA.1-1.r1 --name SST_2006_2007 --time "2006-01-01,2007-12-31" --region " -175,-10,-115,10" --vars "analysed_sst,analysis_error"

rmdir /S /Q uc06
mkdir uc06
cd uc06

rem Start interactive session by initialising an empty workspace
cate ws init

rem Open the datasets and assign to resource names
cate res open soil local.SOIL_2007
rem Doesn't work see Issue #257
cate res open sst local.SST_2006_2007

rem Perform temporal aggregation
cate res set soil_mon temporal_aggregation ds=@soil
cate res set sst_mon temporal_aggregation ds=@sst

rem Perform Long term averaging
cate res set sst_lta long_term_average ds=@sst_mon

rem Save the long term average dataset in the current directory
cate res write sst_lta sst_lta.nc

rem Perform ENSO index calculation
cate res set enso enso_nino34 ds=@sst_mon var="analysed_sst" file="sst_lta.nc"

rem Select a point of soil moisture in south of India
cate res set soil_mon_point tseries_point ds=@soil_mon point="78,12" var="sm"

rem Subset the datasets with a one month lag
cate res set soil_jannov subset_temporal ds=@soil_mon_point time_range="2007-01-01,2007-11-01"
cate res set enso_decoct subset_temporal ds=@enso time_range="2006-12-01,2007-10-01"

rem Perform correlation calculation
cate res set corr pearson_correlation_scalar ds_x=@enso_decoct ds_y=@soil_jannov var_x="ENSO N3.4 Index" var_y="sm"
cate res print corr

rem Save and close the workspace
cate ws save
cate ws close
rem Exit the interactive session
cate ws exit --yes

cd ..

use same soil moisture data source as in uc06.sh


application.bat - 2015 - Boishardy ###
version = "1.2"

application.bat - 2015 - Boishardy ###
version = "1.2.1"

update minor version

update minor version


@echo off

pushd %1

if exist %1\node_modules\azure-cli\bin\azure (
  call npm update azure-cli
) else (
  call npm install azure-cli
)

if exist %1\node_modules\kudusync\bin\kudusync (
  call npm update kudusync
) else (
  call npm install kudusync
)

popd

@echo off

pushd %1

if exist %1\node_modules\azure-cli\bin\azure (
  cmd /c npm update azure-cli
) else (
  cmd /c npm install azure-cli
)

IF %ERRORLEVEL% NEQ 0 goto error

if exist %1\node_modules\kudusync\bin\kudusync (
  cmd /c npm update kudusync
) else (
  cmd /c npm install kudusync
)

popd

Fix npm install intermittent failures.

Fix npm install intermittent failures.


@echo off

powershell -NoProfile -ExecutionPolicy unrestricted -Command "& {.\publish.ps1 -PackageName 'Burrows'; exit $error.Count}"

powershell -NoProfile -ExecutionPolicy unrestricted -Command "& {.\publish.ps1 -PackageName 'Burrows.Autofac'; exit $error.Count}"

powershell -NoProfile -ExecutionPolicy unrestricted -Command "& {.\publish.ps1 -PackageName 'Burrows.NLog'; exit $error.Count}"

powershell -NoProfile -ExecutionPolicy unrestricted -Command "& {.\publish.ps1 -PackageName 'Burrows.Log4Net'; exit $error.Count}"

powershell -NoProfile -ExecutionPolicy unrestricted -Command "& {.\publish.ps1 -PackageName 'Burrows.NHib'; exit $error.Count}"

pause

@echo off

powershell -NoProfile -ExecutionPolicy unrestricted -Command "& {.\archive.ps1; exit $error.Count}"

powershell -NoProfile -ExecutionPolicy unrestricted -Command "& {.\publish.ps1 -PackageName 'Burrows'; exit $error.Count}"

powershell -NoProfile -ExecutionPolicy unrestricted -Command "& {.\publish.ps1 -PackageName 'Burrows.Autofac'; exit $error.Count}"

powershell -NoProfile -ExecutionPolicy unrestricted -Command "& {.\publish.ps1 -PackageName 'Burrows.NLog'; exit $error.Count}"

powershell -NoProfile -ExecutionPolicy unrestricted -Command "& {.\publish.ps1 -PackageName 'Burrows.Log4Net'; exit $error.Count}"

powershell -NoProfile -ExecutionPolicy unrestricted -Command "& {.\publish.ps1 -PackageName 'Burrows.NHib'; exit $error.Count}"

pause

Update to publish

Update to publish


@echo off
if not "%~1"=="" call :Elevate %* 2>"%Temp%\%~n0.log" && exit /b || ( call :Error & exit /b )
call :IsAdmin && ( call :Futile & exit /b )
call :ElevateMe 2>"%Temp%\%~n0.log" || ( call :Error & exit /b )
exit /b
:Elevate <Executable> [Arguments]
setlocal DisableDelayedExpansion
PowerShell -NoProfile -ExecutionPolicy RemoteSigned -Command "$0 = '%1'; $cl = '%*'; $ar = $cl.Substring($0.Length); if (![bool]$ar) {$ar = ' '}; start $0.Trim([char]0x22) -Verb runas -ArgumentList $ar -WorkingDirectory (cvpa .); exit(!$?);"
endlocal
exit /b
:ElevateMe
setlocal DisableDelayedExpansion
PowerShell -NoProfile -ExecutionPolicy RemoteSigned -Command "gwmi -Class Win32_Process -Filter ('ProcessId = ' + $pid) | foreach { $parent = gwmi -Class Win32_Process -Filter ('ProcessId = ' + $_.ParentProcessId)}; if ( $parent.ExecutablePath -like '*cmd.exe' ) { $gparent = $parent } else { $gparent = gwmi -Class Win32_Process -Filter ('ProcessId = ' + $parent.ParentProcessId) }; if ( $gparent.CommandLine.Length -gt $gparent.ExecutablePath.Length ) { $args = ($gparent.CommandLine.Trim().Trim([char]0x22)).Substring($gparent.ExecutablePath.Length) }; if ( $var -eq $null ) { $args = ' ' }; start $gparent.ExecutablePath -Verb runas -ArgumentList $args -WorkingDirectory (cvpa .); exit(!$?);"
endlocal
exit /b
:Error
:: TODO display usage information.
echo.Failed to elevate with Administrator privileges
echo.See "%Temp%\%~n0.log" for details.
exit /b
:Futile
echo.Session already has Administrator privileges
exit /b
:IsAdmin
setlocal DisableDelayedExpansion
PowerShell -NoProfile -ExecutionPolicy RemoteSigned -Command "exit(!(new-object System.Security.Principal.WindowsPrincipal([System.Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator));"
endlocal
exit /b

@echo off
if not "%~1"=="" call :Elevate %* 2>"%Temp%\%~n0.log" && exit /b || ( call :Error & exit /b )
call :IsAdmin && ( call :Futile & exit /b )
call :ElevateMe 2>"%Temp%\%~n0.log" || ( call :Error & exit /b )
exit /b
:Elevate <Executable> [Arguments]
setlocal DisableDelayedExpansion
PowerShell -NoProfile -ExecutionPolicy RemoteSigned -Command "$0 = '%1'; $cl = '%*'; $ar = $cl.Substring($0.Length); if (![bool]$ar) {$ar = ' '}; start $0.Trim([char]0x22) -Verb runas -ArgumentList $ar -WorkingDirectory (cvpa .); exit(!$?);"
endlocal
exit /b
:ElevateMe
:: ElevateMe does not work from inside cmd.exe due to batch files running in the same process, causing the grand parent to be elevated.  Can work for cmd and powershell, or for everything bug cmd. if ( $parent.ExecutablePath -like '*cmd.exe' ) { $gparent = $parent } else { ... }
setlocal DisableDelayedExpansion
PowerShell -NoProfile -ExecutionPolicy RemoteSigned -Command "gwmi -Class Win32_Process -Filter ('ProcessId = ' + $pid) | foreach { $parent = gwmi -Class Win32_Process -Filter ('ProcessId = ' + $_.ParentProcessId)}; $gparent = gwmi -Class Win32_Process -Filter ('ProcessId = ' + $parent.ParentProcessId); if ( $gparent.CommandLine.Length -gt $gparent.ExecutablePath.Length ) { $args = ($gparent.CommandLine.Trim().Trim([char]0x22)).Substring($gparent.ExecutablePath.Length) }; if ( $var -eq $null ) { $args = ' ' }; start $gparent.ExecutablePath -Verb runas -ArgumentList $args -WorkingDirectory (cvpa .); exit(!$?);"
:: TODO if failed, Attempt elevate with execution path
endlocal
exit /b
:Error
echo.Failed to elevate with Administrator privileges
echo.See "%Temp%\%~n0.log" for details.
echo.If attempting to elevate cmd.exe, use: 'elevate cmd'
exit /b
:Futile
echo.Session already has Administrator privileges
exit /b
:IsAdmin
setlocal DisableDelayedExpansion
PowerShell -NoProfile -ExecutionPolicy RemoteSigned -Command "exit(!(new-object System.Security.Principal.WindowsPrincipal([System.Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator));"
endlocal
exit /b

add note about specifically elevating cmd.exe


setlocal EnableDelayedExpansion

if "%ARCH%"=="64" (
    set WIN64="WIN64=YES"
) else (
    set WIN64=
)

:: Work out MSVC_VER - needed for build process.
:: Currently guess from Python version
if  %vc% LEQ 9 set MSVC_VER=1500
if  %vc% GTR 9 set MSVC_VER=1900

:: Get the minor/major version of poppler from the %poppler% environment
:: variable that is set by conda-build
FOR /F "tokens=1,2 delims=." %%a IN ("%poppler%") DO (
  set POPPLER_MAJOR_VERSION=%%a
  set POPPLER_MINOR_VERSION=%%b
)

:: Need consistent flags between build and install.
set BLD_OPTS=%WIN64% ^
    MSVC_VER=%MSVC_VER% ^
    GDAL_HOME=%LIBRARY_PREFIX% ^
    BINDIR=%LIBRARY_BIN% ^
    LIBDIR=%LIBRARY_LIB% ^
    INCDIR=%LIBRARY_INC% ^
    DATADIR=%LIBRARY_PREFIX%\share\gdal ^
    CURL_INC="-I%LIBRARY_INC%" ^
    CURL_LIB="%LIBRARY_LIB%\libcurl.lib wsock32.lib wldap32.lib winmm.lib" ^
    EXPAT_DIR=%LIBRARY_PREFIX% ^
    EXPAT_INCLUDE="-I%LIBRARY_INC%" ^
    EXPAT_LIB=%LIBRARY_LIB%\expat.lib ^
    FITS_PLUGIN=NO ^
    FITS_INC_DIR=%LIBRARY_INC% ^
    FITS_LIB="%LIBRARY_LIB%\cfitsio.lib" ^
    FREEXL_CFLAGS="-I%LIBRARY_INC%" ^
    FREEXL_LIBS=%LIBRARY_LIB%\freexl_i.lib ^
    GEOS_CFLAGS="-I%LIBRARY_INC% -DHAVE_GEOS" ^
    GEOS_DIR=%LIBRARY_PREFIX% ^
    GEOS_LIB=%LIBRARY_LIB%\geos_c.lib ^
    HDF4_DIR=%LIBRARY_PREFIX% ^
    HDF4_HAS_MAXOPENFILES=YES ^
    HDF4_LIB="%LIBRARY_LIB%\hdf.lib %LIBRARY_LIB%\mfhdf.lib %LIBRARY_LIB%\xdr.lib" ^
    HDF5_DIR=%LIBRARY_PREFIX% ^
    HDF5_LIB=%LIBRARY_LIB%\hdf5.lib ^
    HDF5_H5_IS_DLL=YES ^
    TILEDB_ENABLED=YES ^
    TILEDB_DIR=%LIBRARY_PREFIX% ^
    TILEDB_LIBS=%LIBRARY_LIB%\tiledb.lib ^
    JPEGDIR=%LIBRARY_INC% ^
    JPEG_EXTERNAL_LIB=1 ^
    JPEG_LIB=%LIBRARY_LIB%\libjpeg.lib ^
    KEA_CFLAGS="-I%LIBRARY_INC%" ^
    KEA_LIB="%LIBRARY_LIB%\hdf5_cpp.lib %LIBRARY_LIB%\libkea.lib" ^
    NETCDF_INC_DIR=%LIBRARY_INC% ^
    NETCDF_LIB=%LIBRARY_LIB%\netcdf.lib ^
    NETCDF_SETTING=yes ^
    NETCDF_HAS_NC4=yes ^
    OPENJPEG_CFLAGS="-I%LIBRARY_INC%\openjpeg-2.4" ^
    OPENJPEG_ENABLED=YES ^
    OPENJPEG_LIB=%LIBRARY_LIB%\openjp2.lib ^
    PG_INC_DIR=%LIBRARY_INC% ^
    PG_LIB=%LIBRARY_LIB%\libpq.lib ^
    PNGDIR=%LIBRARY_INC% ^
    PNG_EXTERNAL_LIB=1 ^
    PNG_LIB=%LIBRARY_LIB%\libpng.lib ^
    PROJ_FLAGS="-DPROJ_STATIC" ^
    PROJ_INCLUDE="-I%LIBRARY_INC%" ^
    PROJ_LIBRARY=%LIBRARY_LIB%\proj.lib ^
    SPATIALITE_412_OR_LATER=yes ^
    SQLITE_INC="-I%LIBRARY_INC% -DHAVE_SPATIALITE" ^
    SQLITE_LIB="%LIBRARY_LIB%\sqlite3.lib %LIBRARY_LIB%\spatialite_i.lib" ^
    TIFF_INC="-I%LIBRARY_INC%" ^
    TIFF_LIB=%LIBRARY_LIB%\tiff.lib ^
    TIFF_OPTS=-DBIGTIFF_SUPPORT ^
    XERCES_DIR=%LIBRARY_PREFIX% ^
    XERCES_INCLUDE="-I%LIBRARY_INC% -I%LIBRARY_INC%\xercesc" ^
    XERCES_LIB=%LIBRARY_LIB%\xerces-c_3.lib ^
    GEOTIFF_INC="-I%LIBRARY_INC%" ^
    GEOTIFF_LIB=%LIBRARY_LIB%\geotiff_i.lib ^
    LIBICONV_INCLUDE="-I%LIBRARY_INC% -DICONV_CONST= " ^
    LIBICONV_LIBRARY="%LIBRARY_LIB%\iconv.lib" ^
    POPPLER_ENABLED=YES ^
    POPPLER_CFLAGS="-I%LIBRARY_INC%\poppler -DPOPPLER_HAS_OPTCONTENT= -DPOPPLER_BASE_STREAM_HAS_TWO_ARGS= " ^
    POPPLER_MAJOR_VERSION=%POPPLER_MAJOR_VERSION% ^
    POPPLER_MINOR_VERSION=%POPPLER_MINOR_VERSION% ^
    POPPLER_LIBS="%LIBRARY_LIB%\poppler.lib" ^
    WEBP_ENABLED=YES ^
    WEBP_CFLAGS="-I%LIBRARY_INC%" ^
    WEBP_LIBS="%LIBARY_LIB%\libwebp.lib" ^
    ZSTD_CFLAGS="-I%LIBRARY_INC%" ^
    ZSTD_LIBS="%LIBRARY_LIB%\libzstd.lib" ^
    LIBKML_DIR="%LIBRARY_PREFIX%" ^
    LIBKML_INCLUDE="-I%LIBRARY_INC%" ^
    LIBKML_LIBS="%LIBRARY_LIB%\kmlbase.lib %LIBRARY_LIB%\kmlconvenience.lib %LIBRARY_LIB%\kmldom.lib %LIBRARY_LIB%\kmlengine.lib %LIBRARY_LIB%\kmlregionator.lib %LIBRARY_LIB%\kmlxsd.lib %LIBRARY_LIB%\minizip.lib %LIBRARY_LIB%\uriparser.lib"

endlocal && set BLD_OPTS=%BLD_OPTS%

setlocal EnableDelayedExpansion

if "%ARCH%"=="64" (
    set WIN64="WIN64=YES"
) else (
    set WIN64=
)

:: Work out MSVC_VER - needed for build process.
:: Currently guess from Python version
if  %vc% LEQ 9 set MSVC_VER=1500
if  %vc% GTR 9 set MSVC_VER=1900

:: Get the minor/major version of poppler from the %poppler% environment
:: variable that is set by conda-build
FOR /F "tokens=1,2 delims=." %%a IN ("%poppler%") DO (
  set POPPLER_MAJOR_VERSION=%%a
  set POPPLER_MINOR_VERSION=%%b
)
:: remove leading zeros
set /a POPPLER_MINOR_VERSION=10000%POPPLER_MINOR_VERSION% %% 10000

:: Need consistent flags between build and install.
set BLD_OPTS=%WIN64% ^
    MSVC_VER=%MSVC_VER% ^
    GDAL_HOME=%LIBRARY_PREFIX% ^
    BINDIR=%LIBRARY_BIN% ^
    LIBDIR=%LIBRARY_LIB% ^
    INCDIR=%LIBRARY_INC% ^
    DATADIR=%LIBRARY_PREFIX%\share\gdal ^
    CURL_INC="-I%LIBRARY_INC%" ^
    CURL_LIB="%LIBRARY_LIB%\libcurl.lib wsock32.lib wldap32.lib winmm.lib" ^
    EXPAT_DIR=%LIBRARY_PREFIX% ^
    EXPAT_INCLUDE="-I%LIBRARY_INC%" ^
    EXPAT_LIB=%LIBRARY_LIB%\expat.lib ^
    FITS_PLUGIN=NO ^
    FITS_INC_DIR=%LIBRARY_INC% ^
    FITS_LIB="%LIBRARY_LIB%\cfitsio.lib" ^
    FREEXL_CFLAGS="-I%LIBRARY_INC%" ^
    FREEXL_LIBS=%LIBRARY_LIB%\freexl_i.lib ^
    GEOS_CFLAGS="-I%LIBRARY_INC% -DHAVE_GEOS" ^
    GEOS_DIR=%LIBRARY_PREFIX% ^
    GEOS_LIB=%LIBRARY_LIB%\geos_c.lib ^
    HDF4_DIR=%LIBRARY_PREFIX% ^
    HDF4_HAS_MAXOPENFILES=YES ^
    HDF4_LIB="%LIBRARY_LIB%\hdf.lib %LIBRARY_LIB%\mfhdf.lib %LIBRARY_LIB%\xdr.lib" ^
    HDF5_DIR=%LIBRARY_PREFIX% ^
    HDF5_LIB=%LIBRARY_LIB%\hdf5.lib ^
    HDF5_H5_IS_DLL=YES ^
    TILEDB_ENABLED=YES ^
    TILEDB_DIR=%LIBRARY_PREFIX% ^
    TILEDB_LIBS=%LIBRARY_LIB%\tiledb.lib ^
    JPEGDIR=%LIBRARY_INC% ^
    JPEG_EXTERNAL_LIB=1 ^
    JPEG_LIB=%LIBRARY_LIB%\libjpeg.lib ^
    KEA_CFLAGS="-I%LIBRARY_INC%" ^
    KEA_LIB="%LIBRARY_LIB%\hdf5_cpp.lib %LIBRARY_LIB%\libkea.lib" ^
    NETCDF_INC_DIR=%LIBRARY_INC% ^
    NETCDF_LIB=%LIBRARY_LIB%\netcdf.lib ^
    NETCDF_SETTING=yes ^
    NETCDF_HAS_NC4=yes ^
    OPENJPEG_CFLAGS="-I%LIBRARY_INC%\openjpeg-2.4" ^
    OPENJPEG_ENABLED=YES ^
    OPENJPEG_LIB=%LIBRARY_LIB%\openjp2.lib ^
    PG_INC_DIR=%LIBRARY_INC% ^
    PG_LIB=%LIBRARY_LIB%\libpq.lib ^
    PNGDIR=%LIBRARY_INC% ^
    PNG_EXTERNAL_LIB=1 ^
    PNG_LIB=%LIBRARY_LIB%\libpng.lib ^
    PROJ_FLAGS="-DPROJ_STATIC" ^
    PROJ_INCLUDE="-I%LIBRARY_INC%" ^
    PROJ_LIBRARY=%LIBRARY_LIB%\proj.lib ^
    SPATIALITE_412_OR_LATER=yes ^
    SQLITE_INC="-I%LIBRARY_INC% -DHAVE_SPATIALITE" ^
    SQLITE_LIB="%LIBRARY_LIB%\sqlite3.lib %LIBRARY_LIB%\spatialite_i.lib" ^
    TIFF_INC="-I%LIBRARY_INC%" ^
    TIFF_LIB=%LIBRARY_LIB%\tiff.lib ^
    TIFF_OPTS=-DBIGTIFF_SUPPORT ^
    XERCES_DIR=%LIBRARY_PREFIX% ^
    XERCES_INCLUDE="-I%LIBRARY_INC% -I%LIBRARY_INC%\xercesc" ^
    XERCES_LIB=%LIBRARY_LIB%\xerces-c_3.lib ^
    GEOTIFF_INC="-I%LIBRARY_INC%" ^
    GEOTIFF_LIB=%LIBRARY_LIB%\geotiff_i.lib ^
    LIBICONV_INCLUDE="-I%LIBRARY_INC% -DICONV_CONST= " ^
    LIBICONV_LIBRARY="%LIBRARY_LIB%\iconv.lib" ^
    POPPLER_ENABLED=YES ^
    POPPLER_CFLAGS="-I%LIBRARY_INC%\poppler -DPOPPLER_HAS_OPTCONTENT= -DPOPPLER_BASE_STREAM_HAS_TWO_ARGS= " ^
    POPPLER_MAJOR_VERSION=%POPPLER_MAJOR_VERSION% ^
    POPPLER_MINOR_VERSION=%POPPLER_MINOR_VERSION% ^
    POPPLER_LIBS="%LIBRARY_LIB%\poppler.lib" ^
    WEBP_ENABLED=YES ^
    WEBP_CFLAGS="-I%LIBRARY_INC%" ^
    WEBP_LIBS="%LIBARY_LIB%\libwebp.lib" ^
    ZSTD_CFLAGS="-I%LIBRARY_INC%" ^
    ZSTD_LIBS="%LIBRARY_LIB%\libzstd.lib" ^
    LIBKML_DIR="%LIBRARY_PREFIX%" ^
    LIBKML_INCLUDE="-I%LIBRARY_INC%" ^
    LIBKML_LIBS="%LIBRARY_LIB%\kmlbase.lib %LIBRARY_LIB%\kmlconvenience.lib %LIBRARY_LIB%\kmldom.lib %LIBRARY_LIB%\kmlengine.lib %LIBRARY_LIB%\kmlregionator.lib %LIBRARY_LIB%\kmlxsd.lib %LIBRARY_LIB%\minizip.lib %LIBRARY_LIB%\uriparser.lib"

endlocal && set BLD_OPTS=%BLD_OPTS%

add leading zeros hack

add leading zeros hack


tools\nuget\nuget.exe restore RelationScaffolding.sln

set MSBUILD="C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe"

rd /S /Q .\src\RelationScaffolding\bin\Debug
rd /S /Q .\src\RelationScaffolding\bin\Release

%MSBUILD% RelationScaffolding.sln /p:Configuration="Debug"
if %errorlevel% neq 0 exit /b %errorlevel%

%MSBUILD% RelationScaffolding.sln /p:Configuration="Release"
if %errorlevel% neq 0 exit /b %errorlevel%

tools\nuget\nuget.exe restore RelationScaffolding.sln

set MSBUILD="C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe"

rd /S /Q .\src\RelationScaffolding\bin\Debug
rd /S /Q .\src\RelationScaffolding\bin\Release

%MSBUILD% RelationScaffolding.sln /p:Configuration="Debug"
if %errorlevel% neq 0 exit /b %errorlevel%

%MSBUILD% RelationScaffolding.sln /p:Configuration="Release"
if %errorlevel% neq 0 exit /b %errorlevel%

Update to VS2015.

Update to VS2015.


set projectPath=%~dp0
if %projectPath:~-1%==\ set projectPath=%projectPath:~0,-1%

set releasePath=%projectPath%\.release
mkdir "%releasePath%"

for /f "tokens=*" %%a in ('type version.txt') do set version=%%a

del "%releasePath%\shareical_%version%.zip"
"build_tools\7za.exe" a -tzip -r "%releasePath%\shareical_%version%.zip" "%projectPath%\*.*" -xr!.* -xr!build_tools -xr!components -xr!build.bat -xr!composer.json -xr!composer.lock -xr!composer.phar -xr!shareical.phpproj -xr!shareical.phpproj.user -xr!shareical.sln

set projectPath=%~dp0
if %projectPath:~-1%==\ set projectPath=%projectPath:~0,-1%

set releasePath=%projectPath%\.release
mkdir "%releasePath%"

for /f "tokens=*" %%a in ('type version.txt') do set version=%%a

del "%releasePath%\shareical_%version%.zip"
"build_tools\7za.exe" a -tzip -r "%releasePath%\shareical_%version%.zip" "%projectPath%\*.*" -xr!.* -xr!build_tools -xr!build.bat -xr!composer.json -xr!composer.lock -xr!composer.phar -xr!shareical.phpproj -xr!shareical.phpproj.user -xr!shareical.sln
"build_tools\7za.exe" d -tzip -r "%releasePath%\shareical_%version%.zip" components

Fix missing files in release ZIP

Fix missing files in release ZIP


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

.nuget\NuGet.exe restore JabbR.sln -configFile %~dp0\.nuget\NuGet.config -nocache
msbuild %~dp0\Build\Build.proj /p:Configuration="%config%" /v:M /fl /flp:LogFile=msbuild.log;Verbosity=Normal /nr:false

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

.nuget\NuGet.exe restore JabbR.sln -configFile "%~dp0.nuget\NuGet.config" -nocache
msbuild "%~dp0Build\Build.proj" /p:Configuration="%config%" /v:M /fl /flp:LogFile=msbuild.log;Verbosity=Normal /nr:false

fix #1074 build.cmd issues with spaces in repository paths


@echo off

pushd %~dp0

SET PACKAGEPATH=.\packages\
SET NUGET=.\tools\nuget\NuGet.exe
SET NUGETOPTIONS=-ConfigFile .\tools\nuget\NuGet.Config -OutputDirectory %PACKAGEPATH% -ExcludeVersion

IF NOT EXIST %PACKAGEPATH%FAKE\Ver_4.25.4 (
  RD /S/Q %PACKAGEPATH%FAKE
  %NUGET% install FAKE -Version 4.25.4 %NUGETOPTIONS%
  COPY NUL %PACKAGEPATH%FAKE\Ver_4.25.4
)

IF NOT EXIST %PACKAGEPATH%FAKE.BuildLib\Ver_0.3.4 (
  RD /S/Q %PACKAGEPATH%FAKE.BuildLib
  %NUGET% install FAKE.BuildLib -Version 0.3.4 %NUGETOPTIONS%
  COPY NUL %PACKAGEPATH%FAKE.BuildLib\Ver_0.3.4
)

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

popd

@echo off

pushd %~dp0

SET PACKAGEPATH=.\packages\
SET NUGET=.\tools\nuget\NuGet.exe
SET NUGETOPTIONS=-ConfigFile .\tools\nuget\NuGet.Config -OutputDirectory %PACKAGEPATH% -ExcludeVersion

IF NOT EXIST %PACKAGEPATH%FAKE\Ver_4.28.0 (
  RD /S/Q %PACKAGEPATH%FAKE
  %NUGET% install FAKE -Version 4.28.0 %NUGETOPTIONS%
  COPY NUL %PACKAGEPATH%FAKE\Ver_4.28.0
)

IF NOT EXIST %PACKAGEPATH%FAKE.BuildLib\Ver_0.3.6 (
  RD /S/Q %PACKAGEPATH%FAKE.BuildLib
  %NUGET% install FAKE.BuildLib -Version 0.3.6 %NUGETOPTIONS%
  COPY NUL %PACKAGEPATH%FAKE.BuildLib\Ver_0.3.6
)

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

popd

Use BuildLib 0.3.6

Use BuildLib 0.3.6


:: Project API
::
:: This file is called whenever a user enters a project, such p999_Meindbender_Sync
::
:: Arguments:
::   %1: Path = Absolute path to projects
:: 	 %2: Name = Name of project
:: 	 %3: Silo = Parent directory name of assets
::
:: Variables:
::   %PROJECTDIR%: Absolute path to project directory
::
:: Example:
::   $ call _mkproject.bat %~dp0ProjectName assets

@echo off

if "%1"=="" goto :missing_projectdir
if not "%3"=="assets" (
  if not "%3"=="film" goto :missing_silo
)

if "%2"=="" goto :missing_name
if "%3"=="" goto :missing_silo

set PROJECTDIR=%1%2
:: This is a variable for the function back.bat.
set PROJECT=%1
set PROJECTNAME=%2

if not exist %PROJECTDIR% (
  echo Creating new project "%PROJECT%"..

  mkdir %PROJECTDIR%\assets
  mkdir %PROJECTDIR%\film
  rem etc..
)

:: Establish base directories for ls() and search() functions.
set MINDBENDER_ROOT=%PROJECTDIR%
set MINDBENDER_SILO=%3

pushd %PROJECTDIR%\%MINDBENDER_SILO%

:: Clear screen
cls

echo+
echo  ASSETS -----------
echo+

:: List available assets, without their .bat suffix
setlocal enabledelayedexpansion
for %%i in (*.bat) do (
    set temp=%%i
    echo   !temp:.bat=!
)

echo+
echo   1. Type first letters of asset
echo   2. Press [TAB] to auto-complete
echo+
echo  --------------------------------------

goto :eof

:missing_name
   	echo ERROR: Missing FULLPATH
   	exit /b
:missing_projectdir
	exit /b
:missing_silo
    echo  Uh oh..
    echo    Specify either "assets" or "film"
    echo+
    echo  Example:
    set temp=%2
    echo    $ %temp% assets
    echo    $ %temp% film
    exit /b

echo+
echo Syntax: _mkproject FULLPATH SUBFOLDER

:: Project API
::
:: This file is called whenever a user enters a project, such p999_Meindbender_Sync
::
:: Arguments:
::   %1: Path = Absolute path to projects
:: 	 %2: Name = Name of project
::   %3: \f02_prod
:: 	 %4: Silo = Parent directory name of assets
::
:: Variables:
::   %PROJECTDIR%: Absolute path to project directory
::
:: Example:
::   $ call _mkproject.bat %~dp0ProjectName assets

@echo off

if "%1"=="" goto :missing_projectdir
if not "%4"=="assets" (
  if not "%4"=="film" goto :missing_silo
)

if "%2"=="" goto :missing_name
if "%4"=="" goto :missing_silo

set PROJECTDIR=%1%2%3
:: This is a variable for the function back.bat.
set PROJECT=%1
set PROJECTNAME=%2

if not exist %PROJECTDIR% (
  echo Creating new project "%PROJECT%"..

  mkdir %PROJECTDIR%\assets
  mkdir %PROJECTDIR%\film
  rem etc..
)

:: Establish base directories for ls() and search() functions.
set MINDBENDER_ROOT=%PROJECTDIR%
set MINDBENDER_SILO=%4

pushd %PROJECTDIR%\%MINDBENDER_SILO%

:: Clear screen
cls

echo+
echo  ASSETS CATEGORY ---
echo+

:: List available assets, without their .bat suffix
setlocal enabledelayedexpansion
for %%i in (*.bat) do (
    set temp=%%i
    echo   !temp:.bat=!
)
endlocal

echo+
echo   1. Type first letters of asset category
echo   2. Press [TAB] to auto-complete
echo+
echo  --------------------------------------

goto :eof

:missing_name
   	echo ERROR: Missing FULLPATH
   	exit /b
:missing_projectdir
	exit /b
:missing_silo
    echo  Uh oh..
    echo    Specify either "assets" or "film"
    echo+
    echo  Example:
    set temp=%2
    echo    $ %temp% assets
    echo    $ %temp% film
    exit /b

echo+
echo Syntax: _mkproject FULLPATH SUBFOLDER

update so it works with _mkassetcate.bat


@echo off

setlocal

set PATH=%CD%\tools;%PATH%

set WGET_ARGS=-c --no-check-certificate
set UNZIP_ARGS=-q

set BASEURL=https://s3.amazonaws.com/rstudio-buildtools/
set GIN_FILE=gin-2.1.2.zip
set GWT_FILE=gwt-2.8.1.zip
set SELENIUM_FILE=selenium-java-2.37.0.zip
set SELENIUM_SERVER_FILE=selenium-server-standalone-2.37.0.jar
set JUNIT_FILE=junit-4.9b3.jar
set GNUDIFF_FILE=gnudiff.zip
set GNUGREP_FILE=gnugrep-2.5.4.zip
set MSYS_SSH_FILE=msys-ssh-1000-18.zip
set SUMATRA_PDF_FILE=SumatraPDF-3.1.1.zip
set WINUTILS_FILE=winutils-1.0.zip
set WINPTY_FILES=winpty-0.4.3-msys2-2.7.0.zip
set OPENSSL_FILES=openssl-1.0.2m.zip

set PANDOC_VERSION=1.19.2.1
set PANDOC_NAME=pandoc-%PANDOC_VERSION%
set PANDOC_FILE=%PANDOC_NAME%.zip

set LIBCLANG_VERSION=3.4
set LIBCLANG_NAME=libclang-%LIBCLANG_VERSION%
set LIBCLANG_FILE=%LIBCLANG_NAME%.zip
set LIBCLANG_HEADERS=builtin-headers
set LIBCLANG_HEADERS_FILE=libclang-%LIBCLANG_HEADERS%.zip

if not exist gnudiff (
  wget %WGET_ARGS% "%BASEURL%%GNUDIFF_FILE%"
  mkdir gnudiff
  echo Unzipping %GNUDIFF_FILE%
  unzip %UNZIP_ARGS% "%GNUDIFF_FILE%" -d gnudiff
  del "%GNUDIFF_FILE%"
)

if not exist gnugrep (
  wget %WGET_ARGS% "%BASEURL%%GNUGREP_FILE%"
  mkdir gnugrep
  echo Unzipping %GNUGREP_FILE%
  unzip %UNZIP_ARGS% "%GNUGREP_FILE%" -d gnugrep
  del "%GNUGREP_FILE%"
)

if not exist msys-ssh-1000-18 (
  wget %WGET_ARGS% "%BASEURL%%MSYS_SSH_FILE%"
  mkdir msys-ssh-1000-18
  echo Unzipping %MSYS_SSH_FILE%
  unzip %UNZIP_ARGS% "%MSYS_SSH_FILE%" -d msys-ssh-1000-18
  del "%MSYS_SSH_FILE%"
)

if not exist sumatra\3.1.1 (
  wget %WGET_ARGS% "%BASEURL%%SUMATRA_PDF_FILE%"
  mkdir sumatra\3.1.1
  echo Unzipping %SUMATRA_PDF_FILE%
  unzip %UNZIP_ARGS% "%SUMATRA_PDF_FILE%" -d sumatra\3.1.1
  del "%SUMATRA_PDF_FILE%"
)

if not exist winutils\1.0 (
  wget %WGET_ARGS% "%BASEURL%%WINUTILS_FILE%"
  mkdir winutils\1.0
  echo Unzipping %WINUTILS_FILE%
  unzip %UNZIP_ARGS% "%WINUTILS_FILE%" -d winutils\1.0
  del "%WINUTILS_FILE%"
)

if not exist winpty-0.4.3-msys2-2.7.0 (
  wget %WGET_ARGS% "%BASEURL%%WINPTY_FILES%"
  echo Unzipping %WINPTY_FILES%
  unzip %UNZIP_ARGS% "%WINPTY_FILES%"
  del %WINPTY_FILES%
)

if not exist %OPENSSL_FILES:~0,-4% (
  wget %WGET_ARGS% "%BASEURL%%OPENSSL_FILES%"
  echo Unzipping %OPENSSL_FILES%
  unzip %UNZIP_ARGS% "%OPENSSL_FILES%"
  del %OPENSSL_FILES%
)

if not exist ..\..\src\gwt\lib (
  mkdir ..\..\src\gwt\lib
)
pushd ..\..\src\gwt\lib

if not exist gin\2.1.2 (
  wget %WGET_ARGS% "%BASEURL%%GIN_FILE%"
  mkdir gin\2.1.2
  echo Unzipping %GIN_FILE%
  unzip %UNZIP_ARGS% "%GIN_FILE%" -d gin\2.1.2
  del "%GIN_FILE%"
)

if not exist gwt\2.8.1 (
  wget %WGET_ARGS% "%BASEURL%%GWT_FILE%"
  echo Unzipping %GWT_FILE%
  unzip %UNZIP_ARGS% "%GWT_FILE%"
  mkdir gwt
  move gwt-2.8.1 gwt\2.8.1
  del "%GWT_FILE%"
)

if not exist selenium\2.37.0 (
  wget %WGET_ARGS% "%BASEURL%%SELENIUM_FILE%"
  echo Unzipping %SELENIUM_FILE%
  unzip %UNZIP_ARGS% "%SELENIUM_FILE%"
  mkdir selenium
  move selenium-2.37.0 selenium\2.37.0
  del "%SELENIUM_FILE%"
)

if not exist selenium\2.37.0\%SELENIUM_SERVER_FILE% (
  wget %WGET_ARGS% "%BASEURL%%SELENIUM_SERVER_FILE%"
  move %SELENIUM_SERVER_FILE% selenium\2.37.0
)

if not exist selenium\chromedriver\2.7 (
  wget %WGET_ARGS% "%BASEURL%chromedriver-win.exe"
  mkdir selenium\chromedriver\2.7
  move chromedriver-win.exe selenium\chromedriver\2.7
)

if not exist %JUNIT_FILE% (
  wget %WGET_ARGS% "%BASEURL%%JUNIT_FILE%"
)

popd

pushd ..\common
set CORE_DICTIONARIES=core-dictionaries.zip
if not exist "dictionaries\en_US.dic" (
  wget %WGET_ARGS% "https://s3.amazonaws.com/rstudio-dictionaries/%CORE_DICTIONARIES%"
  if exist "%CORE_DICTIONARIES%" (
     mkdir dictionaries
     echo Unzipping %CORE_DICTIONARIES%
     unzip %UNZIP_ARGS% "%CORE_DICTIONARIES%" -d dictionaries
     del "%CORE_DICTIONARIES%"
  )
)

set MATHJAX=mathjax-26.zip
if not exist "mathjax-26" (
  wget %WGET_ARGS% "https://s3.amazonaws.com/rstudio-buildtools/%MATHJAX%"
  if exist "%MATHJAX%" (
     mkdir mathjax-26
     echo Unzipping %MATHJAX%
     unzip %UNZIP_ARGS% "%MATHJAX%"
     del "%MATHJAX%"
  )
)

if not exist pandoc\%PANDOC_VERSION% (
  wget %WGET_ARGS% "%BASEURL%%PANDOC_FILE%"
  echo Unzipping %PANDOC_FILE%
  unzip %UNZIP_ARGS% "%PANDOC_FILE%"
  mkdir pandoc\%PANDOC_VERSION%
  copy "%PANDOC_NAME%\windows\pandoc*" "pandoc\%PANDOC_VERSION%""
  del %PANDOC_FILE%
  rmdir /s /q %PANDOC_NAME%
)

if not exist libclang\%LIBCLANG_VERSION% (
  wget %WGET_ARGS% "%BASEURL%%LIBCLANG_FILE%"
  echo Unzipping %LIBCLANG_FILE%
  unzip %UNZIP_ARGS% "%LIBCLANG_FILE%"
  mkdir libclang\%LIBCLANG_VERSION%
  xcopy /s "%LIBCLANG_NAME%\windows\mingw" "libclang\%LIBCLANG_VERSION%"
  del %LIBCLANG_FILE%
  rmdir /s /q %LIBCLANG_NAME%
)

if not exist libclang\%LIBCLANG_HEADERS% (
  wget %WGET_ARGS% "%BASEURL%%LIBCLANG_HEADERS_FILE%"
  echo Unzipping %LIBCLANG_HEADERS%
  unzip %UNZIP_ARGS% "%LIBCLANG_HEADERS_FILE%" -d libclang
  del %LIBCLANG_HEADERS_FILE%
)

install-packages.cmd

popd

@echo off

setlocal

set PATH=%CD%\tools;%PATH%

set WGET_ARGS=-c --no-check-certificate
set UNZIP_ARGS=-q

set BASEURL=https://s3.amazonaws.com/rstudio-buildtools/
set GIN_FILE=gin-2.1.2.zip
set GWT_FILE=gwt-2.8.1.zip
set SELENIUM_FILE=selenium-java-2.37.0.zip
set SELENIUM_SERVER_FILE=selenium-server-standalone-2.37.0.jar
set JUNIT_FILE=junit-4.9b3.jar
set GNUDIFF_FILE=gnudiff.zip
set GNUGREP_FILE=gnugrep-2.5.4.zip
set MSYS_SSH_FILE=msys-ssh-1000-18.zip
set SUMATRA_PDF_FILE=SumatraPDF-3.1.1.zip
set WINUTILS_FILE=winutils-1.0.zip
set WINPTY_FILES=winpty-0.4.3-msys2-2.7.0.zip
set OPENSSL_FILES=openssl-1.0.2m.zip
set BOOST_FILES=boost-1.65.1-win-msvc14.zip

set PANDOC_VERSION=1.19.2.1
set PANDOC_NAME=pandoc-%PANDOC_VERSION%
set PANDOC_FILE=%PANDOC_NAME%.zip

set LIBCLANG_VERSION=3.4
set LIBCLANG_NAME=libclang-%LIBCLANG_VERSION%
set LIBCLANG_FILE=%LIBCLANG_NAME%.zip
set LIBCLANG_HEADERS=builtin-headers
set LIBCLANG_HEADERS_FILE=libclang-%LIBCLANG_HEADERS%.zip

if not exist gnudiff (
  wget %WGET_ARGS% "%BASEURL%%GNUDIFF_FILE%"
  mkdir gnudiff
  echo Unzipping %GNUDIFF_FILE%
  unzip %UNZIP_ARGS% "%GNUDIFF_FILE%" -d gnudiff
  del "%GNUDIFF_FILE%"
)

if not exist gnugrep (
  wget %WGET_ARGS% "%BASEURL%%GNUGREP_FILE%"
  mkdir gnugrep
  echo Unzipping %GNUGREP_FILE%
  unzip %UNZIP_ARGS% "%GNUGREP_FILE%" -d gnugrep
  del "%GNUGREP_FILE%"
)

if not exist msys-ssh-1000-18 (
  wget %WGET_ARGS% "%BASEURL%%MSYS_SSH_FILE%"
  mkdir msys-ssh-1000-18
  echo Unzipping %MSYS_SSH_FILE%
  unzip %UNZIP_ARGS% "%MSYS_SSH_FILE%" -d msys-ssh-1000-18
  del "%MSYS_SSH_FILE%"
)

if not exist sumatra\3.1.1 (
  wget %WGET_ARGS% "%BASEURL%%SUMATRA_PDF_FILE%"
  mkdir sumatra\3.1.1
  echo Unzipping %SUMATRA_PDF_FILE%
  unzip %UNZIP_ARGS% "%SUMATRA_PDF_FILE%" -d sumatra\3.1.1
  del "%SUMATRA_PDF_FILE%"
)

if not exist winutils\1.0 (
  wget %WGET_ARGS% "%BASEURL%%WINUTILS_FILE%"
  mkdir winutils\1.0
  echo Unzipping %WINUTILS_FILE%
  unzip %UNZIP_ARGS% "%WINUTILS_FILE%" -d winutils\1.0
  del "%WINUTILS_FILE%"
)

if not exist winpty-0.4.3-msys2-2.7.0 (
  wget %WGET_ARGS% "%BASEURL%%WINPTY_FILES%"
  echo Unzipping %WINPTY_FILES%
  unzip %UNZIP_ARGS% "%WINPTY_FILES%"
  del %WINPTY_FILES%
)

if not exist %OPENSSL_FILES:~0,-4% (
  wget %WGET_ARGS% "%BASEURL%%OPENSSL_FILES%"
  echo Unzipping %OPENSSL_FILES%
  unzip %UNZIP_ARGS% "%OPENSSL_FILES%"
  del %OPENSSL_FILES%
)

if not exist %BOOST_FILES:~0,-4% (
  wget %WGET_ARGS% "%BASEURL%%BOOST_FILES%"
  echo Unzipping %BOOST_FILES%
  unzip %UNZIP_ARGS% "%BOOST_FILES%"
  del %BOOST_FILES%
)

if not exist ..\..\src\gwt\lib (
  mkdir ..\..\src\gwt\lib
)
pushd ..\..\src\gwt\lib

if not exist gin\2.1.2 (
  wget %WGET_ARGS% "%BASEURL%%GIN_FILE%"
  mkdir gin\2.1.2
  echo Unzipping %GIN_FILE%
  unzip %UNZIP_ARGS% "%GIN_FILE%" -d gin\2.1.2
  del "%GIN_FILE%"
)

if not exist gwt\2.8.1 (
  wget %WGET_ARGS% "%BASEURL%%GWT_FILE%"
  echo Unzipping %GWT_FILE%
  unzip %UNZIP_ARGS% "%GWT_FILE%"
  mkdir gwt
  move gwt-2.8.1 gwt\2.8.1
  del "%GWT_FILE%"
)

if not exist selenium\2.37.0 (
  wget %WGET_ARGS% "%BASEURL%%SELENIUM_FILE%"
  echo Unzipping %SELENIUM_FILE%
  unzip %UNZIP_ARGS% "%SELENIUM_FILE%"
  mkdir selenium
  move selenium-2.37.0 selenium\2.37.0
  del "%SELENIUM_FILE%"
)

if not exist selenium\2.37.0\%SELENIUM_SERVER_FILE% (
  wget %WGET_ARGS% "%BASEURL%%SELENIUM_SERVER_FILE%"
  move %SELENIUM_SERVER_FILE% selenium\2.37.0
)

if not exist selenium\chromedriver\2.7 (
  wget %WGET_ARGS% "%BASEURL%chromedriver-win.exe"
  mkdir selenium\chromedriver\2.7
  move chromedriver-win.exe selenium\chromedriver\2.7
)

if not exist %JUNIT_FILE% (
  wget %WGET_ARGS% "%BASEURL%%JUNIT_FILE%"
)

popd

pushd ..\common
set CORE_DICTIONARIES=core-dictionaries.zip
if not exist "dictionaries\en_US.dic" (
  wget %WGET_ARGS% "https://s3.amazonaws.com/rstudio-dictionaries/%CORE_DICTIONARIES%"
  if exist "%CORE_DICTIONARIES%" (
     mkdir dictionaries
     echo Unzipping %CORE_DICTIONARIES%
     unzip %UNZIP_ARGS% "%CORE_DICTIONARIES%" -d dictionaries
     del "%CORE_DICTIONARIES%"
  )
)

set MATHJAX=mathjax-26.zip
if not exist "mathjax-26" (
  wget %WGET_ARGS% "https://s3.amazonaws.com/rstudio-buildtools/%MATHJAX%"
  if exist "%MATHJAX%" (
     mkdir mathjax-26
     echo Unzipping %MATHJAX%
     unzip %UNZIP_ARGS% "%MATHJAX%"
     del "%MATHJAX%"
  )
)

if not exist pandoc\%PANDOC_VERSION% (
  wget %WGET_ARGS% "%BASEURL%%PANDOC_FILE%"
  echo Unzipping %PANDOC_FILE%
  unzip %UNZIP_ARGS% "%PANDOC_FILE%"
  mkdir pandoc\%PANDOC_VERSION%
  copy "%PANDOC_NAME%\windows\pandoc*" "pandoc\%PANDOC_VERSION%""
  del %PANDOC_FILE%
  rmdir /s /q %PANDOC_NAME%
)

if not exist libclang\%LIBCLANG_VERSION% (
  wget %WGET_ARGS% "%BASEURL%%LIBCLANG_FILE%"
  echo Unzipping %LIBCLANG_FILE%
  unzip %UNZIP_ARGS% "%LIBCLANG_FILE%"
  mkdir libclang\%LIBCLANG_VERSION%
  xcopy /s "%LIBCLANG_NAME%\windows\mingw" "libclang\%LIBCLANG_VERSION%"
  del %LIBCLANG_FILE%
  rmdir /s /q %LIBCLANG_NAME%
)

if not exist libclang\%LIBCLANG_HEADERS% (
  wget %WGET_ARGS% "%BASEURL%%LIBCLANG_HEADERS_FILE%"
  echo Unzipping %LIBCLANG_HEADERS%
  unzip %UNZIP_ARGS% "%LIBCLANG_HEADERS_FILE%" -d libclang
  del %LIBCLANG_HEADERS_FILE%
)

install-packages.cmd

popd

add Boost to installer script

add Boost to installer script