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

:: ----------------------
:: KUDU Deployment Script
:: Version: 0.1.11
:: ----------------------

:: 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 NOT DEFINED MSBUILD_PATH (
  SET MSBUILD_PATH=%WINDIR%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
)

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

echo Handling .NET Web Application deployment.

:: 1. Restore NuGet packages
IF /I "src\Orchard.sln" NEQ "" (
  call :ExecuteCmd nuget restore "%DEPLOYMENT_SOURCE%\src\Orchard.sln"
  IF !ERRORLEVEL! NEQ 0 goto error
)

:: 2. Build to the temporary path
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\Orchard.proj" /nologo /verbosity:m /t:Precompiled /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="%DEPLOYMENT_TEMP%";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release /p:SolutionDir="%DEPLOYMENT_SOURCE%\src\\" %SCM_BUILD_ARGS%
) ELSE (
  call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\Orchard.proj" /nologo /verbosity:m /t:Precompiled /p:AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release /p:SolutionDir="%DEPLOYMENT_SOURCE%\src\\" %SCM_BUILD_ARGS%
)

IF !ERRORLEVEL! NEQ 0 goto error

:: 3. 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
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: Post deployment stub
IF DEFINED POST_DEPLOYMENT_ACTION call "%POST_DEPLOYMENT_ACTION%"
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: 0.1.11
:: ----------------------

:: 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

:: #region ORCHARD ENVIRONMENTAL VARIABLES
:: ------------
SET SITE_DIR=%~dp0%..
SET DEPLOYMENT_SOURCE=%~dp0%.
SET DEPLOYMENT_TARGET=%SITE_DIR%\wwwroot
SET DEPLOYMENT_TEMP="%DEPLOYMENT_SOURCE%\build\precompiled"
SET CLEAN_LOCAL_DEPLOYMENT_TEMP=true
:: ---------------
:: #endregion ORCHARD ENVIRONMENTAL VARIABLES

SET ARTIFACTS=%SITE_DIR%\artifacts

:: #region For local testing, create artifacts dir
:: ------------
IF NOT EXIST ARTIFACTS (
  mkdir ARTIFACTS
)
:: ------------
:: #endregion

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 NOT DEFINED MSBUILD_PATH (
  SET MSBUILD_PATH=%WINDIR%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
)

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

echo Handling .NET Web Application deployment.

:: 1. Restore NuGet packages
IF /I "src\Orchard.sln" NEQ "" (
  call :ExecuteCmd nuget restore "%DEPLOYMENT_SOURCE%\src\Orchard.sln"
  IF !ERRORLEVEL! NEQ 0 goto error
)

:: 2. Build to the temporary path
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\Orchard.proj" /nologo /verbosity:m /t:Precompiled /p:AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release /p:SolutionDir="%DEPLOYMENT_SOURCE%\src\\" %SCM_BUILD_ARGS%
) ELSE (
  call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\Orchard.proj" /nologo /verbosity:m /t:Build /p:AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release /p:SolutionDir="%DEPLOYMENT_SOURCE%\src\\" %SCM_BUILD_ARGS%
)

IF !ERRORLEVEL! NEQ 0 goto error

:: 3. 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
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: Post deployment stub
IF DEFINED POST_DEPLOYMENT_ACTION call "%POST_DEPLOYMENT_ACTION%"
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.
pause > nul
call :exitSetErrorLevel
call :exitFromFunction 2>nul

:exitSetErrorLevel
exit /b 1

:exitFromFunction
()

:end
endlocal
echo Finished successfully.

Revert "Remove unecessary stuff."

Revert "Remove unecessary stuff."

This reverts commit e52501cd330066ebeffad95cc3123880798da4d0.


@if "%_echo%" neq "1" @echo off

setlocal
set _SCRIPT=%~nx0
set _KUDUZIP=%~dp0Kudu.zip
set _SCMURI=%~1
set _CURLEXE="%ProgramFiles(x86)%\git\bin\curl.exe"

if NOT EXIST %_CURLEXE% (
  REM must put quote to not inteprete ( and )
  set _CURLEXE="%ProgramFiles(x86)%\git\mingw32\bin\curl.exe"
)

if NOT EXIST %_CURLEXE% (
  REM must put quote to not inteprete ( and )
  set _CURLEXE="%ProgramW6432%\git\mingw64\bin\curl.exe"
)

REM Trim quote
set _CURLEXE=%_CURLEXE:"=%

REM first parameter is the deploy uri with embedded cred
if "%_SCMURI%" equ "" (
  call :USAGE
  goto :EOF
)

REM remove any after .net
set _SCMURI=%_SCMURI:.net=&rem.%
set _SCMURI=%_SCMURI%.net

if NOT EXIST "%_KUDUZIP%" (
  @echo "%_KUDUZIP%" does not exists!
  goto :EOF
)

if NOT EXIST "%_CURLEXE%" (
  @echo "%_CURLEXE%" does not exists!
  goto :EOF
)

@echo.
@echo "%_CURLEXE%" -k -v -T "%_KUDUZIP%" "%_SCMURI%/zip"
@echo.
@call "%_CURLEXE%" -k -v -T "%_KUDUZIP%" "%_SCMURI%/zip"
@echo.
@call "%_CURLEXE%" -k -X DELETE "%_SCMURI%/diagnostics/processes/0" >nul 2>&1
if "%ERRORLEVEL%" equ "0" (
  @echo - w3wp.exe restarted
)

exit /b 0

:USAGE
@echo usage: %_SCRIPT% "<scm_uri>"
exit /b 0

REM testing

@if "%_echo%" neq "1" @echo off

setlocal
set _SCRIPT=%~nx0
set _KUDUZIP=%~dp0Kudu.zip
set _SCMURI=%~1
set _CURLEXE="%ProgramFiles(x86)%\git\bin\curl.exe"

if NOT EXIST %_CURLEXE% (
  REM must put quote to not inteprete ( and )
  set _CURLEXE="%ProgramFiles(x86)%\git\mingw32\bin\curl.exe"
)

if NOT EXIST %_CURLEXE% (
  REM must put quote to not inteprete ( and )
  set _CURLEXE="%ProgramW6432%\git\mingw64\bin\curl.exe"
)

REM Trim quote
set _CURLEXE=%_CURLEXE:"=%

REM first parameter is the deploy uri with embedded cred
if "%_SCMURI%" equ "" (
  call :USAGE
  goto :EOF
)

REM remove any after .net
set _SCMURI=%_SCMURI:.net=&rem.%
set _SCMURI=%_SCMURI%.net

if NOT EXIST "%_KUDUZIP%" (
  @echo "%_KUDUZIP%" does not exists!
  goto :EOF
)

if NOT EXIST "%_CURLEXE%" (
  @echo "%_CURLEXE%" does not exists!
  goto :EOF
)

@echo.
@echo "%_CURLEXE%" -k -v -T "%_KUDUZIP%" "%_SCMURI%/api/zip"
@echo.
@call "%_CURLEXE%" -k -v -T "%_KUDUZIP%" "%_SCMURI%/api/zip"
@echo.
@call "%_CURLEXE%" -k -X DELETE "%_SCMURI%/api/processes/0" >nul 2>&1
if "%ERRORLEVEL%" equ "0" (
  @echo - w3wp.exe restarted
)

exit /b 0

:USAGE
@echo usage: %_SCRIPT% "<scm_uri>"
exit /b 0

REM testing

fix DeployPrivateKudu to not use deprecated apis


if NOT DEFINED ClientRevision set ClientRevision=master
if NOT DEFINED KBFSRevision set KBFSRevision=master
if NOT DEFINED UpdaterRevision set UpdaterRevision=master
if NOT DEFINED ReleaseRevision set ReleaseRevision=master

set OUTPUT=echo
if DEFINED SlackBot set OUTPUT=go run %GOPATH%/src/github.com/keybase/slackbot/send/main.go -i=1

if NOT DEFINED DOKAN_PATH set DOKAN_PATH=%GOPATH%\bin\dokan-dev\build84
echo DOKAN_PATH %DOKAN_PATH%

if NOT DEFINED DevEnvDir call "%ProgramFiles(x86)%\\Microsoft Visual Studio 14.0\\vc\\bin\\vcvars32.bat"

IF [%UpdateChannel%] == [] goto:donecheckingdrivers

IF [%UpdateChannel%] == [None] goto:donecheckingdrivers

IF [%UpdateChannel%] == [Test] goto:donecheckingdrivers

:: don't bother with ci or checking out source, etc. for smoke2 build
IF [%UpdateChannel%] == [Smoke2] goto:done_ci

:: Verify driver signing
:: Check both the built .sys files and the msi package.
if NOT DEFINED UNARCHIVE_COMMAND set UNARCHIVE_COMMAND="C:\Program Filess (x86)\7-Zip\7z" e -y

signtool verify /all /kp /v %DOKAN_PATH%\\x64\\Win10Release\\dokan1.sys | find "Issued to: Microsoft Windows Hardware Compatibility Publisher"
IF %ERRORLEVEL% NEQ 0 goto:build_error || EXIT /B 1
signtool verify /all /kp /v %DOKAN_PATH%\\Win32\\Win10Release\\dokan1.sys | find "Issued to: Microsoft Windows Hardware Compatibility Publisher"
IF %ERRORLEVEL% NEQ 0 goto:build_error || EXIT /B 1
%UNARCHIVE_COMMAND% %DOKAN_PATH%\\dokan_wix\\bin\\x64\\release\\Dokan_x64.msi Win10_Sys
IF %ERRORLEVEL% NEQ 0 goto:build_error || EXIT /B 1
signtool verify /all /kp /v Win10_Sys | find "Issued to: Microsoft Windows Hardware Compatibility Publisher"
IF %ERRORLEVEL% NEQ 0 goto:build_error || EXIT /B 1
%UNARCHIVE_COMMAND% %DOKAN_PATH%\\dokan_wix\\bin\\x86\\release\\Dokan_x86.msi Win10_Sys
IF %ERRORLEVEL% NEQ 0 goto:build_error || EXIT /B 1
signtool verify /all /kp /v Win10_Sys | find "Issued to: Microsoft Windows Hardware Compatibility Publisher"
IF %ERRORLEVEL% NEQ 0 goto:build_error || EXIT /B 1

:donecheckingdrivers

call:checkout_keybase client, %ClientRevision% || goto:build_error || EXIT /B 1
call:checkout_keybase kbfs, %KBFSRevision% || goto:build_error || EXIT /B 1
call:checkout_keybase go-updater, %UpdaterRevision% || goto:build_error || EXIT /B 1
call:checkout_keybase release, %ReleaseRevision% || goto:build_error || EXIT /B 1

::wait for CI
if [%UpdateChannel%] == [SmokeCI] call:check_ci  || EXIT /B 1

:done_ci

for /F delims^=^"^ tokens^=2 %%x in ('findstr /C:"Version = " %GOPATH%\src\github.com\keybase\client\go\libkb\version.go') do set LIBKB_VER=%%x

:: release
pushd %GOPATH%\src\github.com\keybase\release
del release.exe
go build
IF %ERRORLEVEL% NEQ 0 (
  goto:build_error || EXIT /B 1
)
for /f %%i in ('release winbuildnumber --version=%LIBKB_VER%') do set BUILD_NUMBER=%%i
echo %BUILD_NUMBER%
popd

if NOT DEFINED BUILD_NUMBER (
  echo bad build number
  goto:build_error || EXIT /B 1
)
:: ensure it's numeric
SET "badbuildnumber="&for /f "delims=0123456789" %%i in ("%BUILD_NUMBER%") do set badbuildnumber=%%i
if defined badbuildnumber (
  echo bad build number
  goto:build_error || EXIT /B 1
)

call %GOPATH%\src\github.com\keybase\client\packaging\windows\build_prerelease.cmd || goto:build_error || EXIT /B 1

::RunQuiet Utility
pushd %GOPATH%\src\github.com\keybase\client\go\tools\runquiet
del rq.hash
del old.hash
powershell -command "wget https://s3.amazonaws.com/prerelease.keybase.io/windows-support/runquiet/runquiet.hash -OutFile old.hash"
git log -1 -- runquiet.go > rq.hash
fc rq.hash old.hash
if %ERRORLEVEL% EQU 0 (
    echo "downloading keybaserq"
    powershell -command "wget https://s3.amazonaws.com/prerelease.keybase.io/windows-support/runquiet/keybaserq.exe -OutFile keybaserq.exe"
) else (
    echo "--- runquiet hashes differ, building keybaserq. Server hash: ---"
    type old.hash
    echo "--- Current hash: ---"
    type rq.hash
    call ..\..\..\packaging\windows\buildrq.bat || goto:build_error || EXIT /B 1
)
popd

call %GOPATH%\src\github.com\keybase\client\packaging\windows\buildui.bat || goto:build_error || EXIT /B 1

::Build Installer
call %GOPATH%\src\github.com\keybase\client\packaging\windows\doinstaller_wix.cmd || goto:build_error || EXIT /B 1

::Publish to S3
if %UpdateChannel% NEQ "None" (
    echo "Uploading %BUILD_TAG%"
    s3browser-con upload prerelease.keybase.io  %GOPATH%\src\github.com\keybase\client\packaging\windows\%BUILD_TAG%\*.exe prerelease.keybase.io/windows  || goto:build_error || EXIT /B 1
    :: Test channel json
    s3browser-con upload prerelease.keybase.io  %GOPATH%\src\github.com\keybase\client\packaging\windows\%BUILD_TAG%\update-windows-prod-test-v2.json prerelease.keybase.io || goto:build_error || EXIT /B 1
) else (
    echo "No update channel"
)

::Invoke SmokeB build
if [%UpdateChannel%] NEQ [Smoke] (
    if [%UpdateChannel%] NEQ [SmokeCI] (
        echo "Not a smoke build"
        goto :no_smokea
    )
)

:: Smoke A json
s3browser-con upload prerelease.keybase.io  %GOPATH%\src\github.com\keybase\client\packaging\windows\%BUILD_TAG%\*.json prerelease.keybase.io/windows-support || goto:build_error || EXIT /B 1

set PrevUpdateChannel=%UpdateChannel%
set UpdateChannel=Smoke2
set smokeASemVer=%KEYBASE_VERSION%
::SlackBot?

::build again
call %GOPATH%\src\github.com\keybase\client\packaging\windows\dorelease.cmd || EXIT /B 1

:: and we're done here

EXIT /B 0

:no_smokea

::Publish smoke updater jsons to S3
if [%UpdateChannel%] NEQ [Smoke2] (
    echo "Non Smoke2 build"
    %OUTPUT% "Successfully built Windows with client: %KEYBASE_VERSION%, kbfs: %KBFS_BUILD%"
    goto :no_smokeb
)
::Smoke B json
s3browser-con upload prerelease.keybase.io  %GOPATH%\src\github.com\keybase\client\packaging\windows\%BUILD_TAG%\*.json prerelease.keybase.io/windows-support  || goto:build_error || EXIT /B 1
set smokeBSemVer=%KEYBASE_VERSION%
%GOPATH%\src\github.com\keybase\release\release announce-build --build-a="%SmokeASemVer%" --build-b="%smokeBSemVer%" --platform="windows" || goto:build_error || EXIT /B 1
%OUTPUT% "Successfully built Windows: --build-a=%SmokeASemVer% --build-b=%smokeBSemVer%
:no_smokeb

echo %ERRORLEVEL%

goto:eof

:checkout_keybase

if EXIST %GOPATH%\src\github.com\keybase\%~1 goto:repoexists
pushd %GOPATH%\src\github.com\keybase
git clone https://github.com/keybase/%~1.git
popd
:repoexists

pushd %GOPATH%\src\github.com\keybase\%~1
git pull origin %~2 || EXIT /B 1
git checkout %~2 || EXIT /B 1
popd
EXIT /B 0

goto:eof

:build_error
%OUTPUT% "Error building Windows"
EXIT /B 1

:check_ci
for /f %%i in ('git -C %GOPATH%\src\github.com\keybase\client rev-parse --short HEAD') do set clientCommit=%%i
for /f %%i in ('git -C %GOPATH%\src\github.com\keybase\kbfs rev-parse --short HEAD') do set kbfsCommit=%%i
echo [%clientCommit%] [%kbfsCommit%]
:: need GITHUB_TOKEN
pushd %GOPATH%\src\github.com\keybase\release
go build || goto:build_error || EXIT /B 1
release wait-ci --repo="client" --commit="%clientCommit%" --context="continuous-integration/jenkins/branch" --context="ci/circleci"  || goto:ci_error
release wait-ci --repo="kbfs" --commit="%kbfsCommit%" --context="continuous-integration/jenkins/branch" --context="ci/circleci"  || goto:ci_error
popd
EXIT /B 0

:ci_error
%OUTPUT% "CI Failure building Windows"
EXIT /B 1

if NOT DEFINED ClientRevision set ClientRevision=master
if NOT DEFINED KBFSRevision set KBFSRevision=master
if NOT DEFINED UpdaterRevision set UpdaterRevision=master
if NOT DEFINED ReleaseRevision set ReleaseRevision=master

set OUTPUT=echo
if DEFINED SlackBot set OUTPUT=go run %GOPATH%/src/github.com/keybase/slackbot/send/main.go -i=1

if NOT DEFINED DOKAN_PATH set DOKAN_PATH=%GOPATH%\bin\dokan-dev\build84
echo DOKAN_PATH %DOKAN_PATH%

if NOT DEFINED DevEnvDir call "%ProgramFiles(x86)%\\Microsoft Visual Studio 14.0\\vc\\bin\\vcvars32.bat"

IF [%UpdateChannel%] == [] goto:donecheckingdrivers

IF [%UpdateChannel%] == [None] goto:donecheckingdrivers

IF [%UpdateChannel%] == [Test] goto:donecheckingdrivers

:: don't bother with ci or checking out source, etc. for smoke2 build
IF [%UpdateChannel%] == [Smoke2] goto:done_ci

:: Verify driver signing
:: Check both the built .sys files and the msi package.
if NOT DEFINED UNARCHIVE_COMMAND set UNARCHIVE_COMMAND="C:\Program Filess (x86)\7-Zip\7z" e -y

signtool verify /all /kp /v %DOKAN_PATH%\\x64\\Win10Release\\dokan1.sys | find "Issued to: Microsoft Windows Hardware Compatibility Publisher"
IF %ERRORLEVEL% NEQ 0 goto:build_error || EXIT /B 1
signtool verify /all /kp /v %DOKAN_PATH%\\Win32\\Win10Release\\dokan1.sys | find "Issued to: Microsoft Windows Hardware Compatibility Publisher"
IF %ERRORLEVEL% NEQ 0 goto:build_error || EXIT /B 1
%UNARCHIVE_COMMAND% %DOKAN_PATH%\\dokan_wix\\bin\\x64\\release\\Dokan_x64.msi Win10_Sys
IF %ERRORLEVEL% NEQ 0 goto:build_error || EXIT /B 1
signtool verify /all /kp /v Win10_Sys | find "Issued to: Microsoft Windows Hardware Compatibility Publisher"
IF %ERRORLEVEL% NEQ 0 goto:build_error || EXIT /B 1
%UNARCHIVE_COMMAND% %DOKAN_PATH%\\dokan_wix\\bin\\x86\\release\\Dokan_x86.msi Win10_Sys
IF %ERRORLEVEL% NEQ 0 goto:build_error || EXIT /B 1
signtool verify /all /kp /v Win10_Sys | find "Issued to: Microsoft Windows Hardware Compatibility Publisher"
IF %ERRORLEVEL% NEQ 0 goto:build_error || EXIT /B 1

:donecheckingdrivers

call:checkout_keybase client, %ClientRevision% || goto:build_error || EXIT /B 1
call:checkout_keybase kbfs, %KBFSRevision% || goto:build_error || EXIT /B 1
call:checkout_keybase go-updater, %UpdaterRevision% || goto:build_error || EXIT /B 1
call:checkout_keybase release, %ReleaseRevision% || goto:build_error || EXIT /B 1

::wait for CI
if [%UpdateChannel%] == [SmokeCI] call:check_ci  || EXIT /B 1

:done_ci

for /F delims^=^"^ tokens^=2 %%x in ('findstr /C:"Version = " %GOPATH%\src\github.com\keybase\client\go\libkb\version.go') do set LIBKB_VER=%%x

:: release
pushd %GOPATH%\src\github.com\keybase\release
del release.exe
go build
IF %ERRORLEVEL% NEQ 0 (
  goto:build_error || EXIT /B 1
)
for /f %%i in ('release winbuildnumber --version=%LIBKB_VER%') do set BUILD_NUMBER=%%i
echo %BUILD_NUMBER%
popd

if NOT DEFINED BUILD_NUMBER (
  echo bad build number
  goto:build_error || EXIT /B 1
)
:: ensure it's numeric
SET "badbuildnumber="&for /f "delims=0123456789" %%i in ("%BUILD_NUMBER%") do set badbuildnumber=%%i
if defined badbuildnumber (
  echo bad build number
  goto:build_error || EXIT /B 1
)

call %GOPATH%\src\github.com\keybase\client\packaging\windows\build_prerelease.cmd || goto:build_error || EXIT /B 1

::RunQuiet Utility
pushd %GOPATH%\src\github.com\keybase\client\go\tools\runquiet
del rq.hash
del old.hash
powershell -command "wget https://s3.amazonaws.com/prerelease.keybase.io/windows-support/runquiet/runquiet.hash -OutFile old.hash"
git log -1 -- runquiet.go > rq.hash
fc rq.hash old.hash
if %ERRORLEVEL% EQU 0 (
    echo "downloading keybaserq"
    powershell -command "wget https://s3.amazonaws.com/prerelease.keybase.io/windows-support/runquiet/keybaserq.exe -OutFile keybaserq.exe"
) else (
    echo "--- runquiet hashes differ, building keybaserq. Server hash: ---"
    type old.hash
    echo "--- Current hash: ---"
    type rq.hash
    call ..\..\..\packaging\windows\buildrq.bat || goto:build_error || EXIT /B 1
)
popd

call %GOPATH%\src\github.com\keybase\client\packaging\windows\buildui.bat || goto:build_error || EXIT /B 1

::Build Installer
call %GOPATH%\src\github.com\keybase\client\packaging\windows\doinstaller_wix.cmd || goto:build_error || EXIT /B 1

::Publish to S3
if %UpdateChannel% NEQ "None" (
    echo "Uploading %BUILD_TAG%"
    s3browser-con upload prerelease.keybase.io  %GOPATH%\src\github.com\keybase\client\packaging\windows\%BUILD_TAG%\Keybase_%BUILD_TAG%.386.exe prerelease.keybase.io/windows  || goto:build_error || EXIT /B 1
    :: Test channel json
    s3browser-con upload prerelease.keybase.io  %GOPATH%\src\github.com\keybase\client\packaging\windows\%BUILD_TAG%\update-windows-prod-test-v2.json prerelease.keybase.io || goto:build_error || EXIT /B 1
) else (
    echo "No update channel"
)

::Invoke SmokeB build
if [%UpdateChannel%] NEQ [Smoke] (
    if [%UpdateChannel%] NEQ [SmokeCI] (
        echo "Not a smoke build"
        goto :no_smokea
    )
)

:: Smoke A json
s3browser-con upload prerelease.keybase.io  %GOPATH%\src\github.com\keybase\client\packaging\windows\%BUILD_TAG%\*.json prerelease.keybase.io/windows-support || goto:build_error || EXIT /B 1

set PrevUpdateChannel=%UpdateChannel%
set UpdateChannel=Smoke2
set smokeASemVer=%KEYBASE_VERSION%
::SlackBot?

::build again
call %GOPATH%\src\github.com\keybase\client\packaging\windows\dorelease.cmd || EXIT /B 1

:: and we're done here

EXIT /B 0

:no_smokea

::Publish smoke updater jsons to S3
if [%UpdateChannel%] NEQ [Smoke2] (
    echo "Non Smoke2 build"
    %OUTPUT% "Successfully built Windows with client: %KEYBASE_VERSION%, kbfs: %KBFS_BUILD%"
    goto :no_smokeb
)
::Smoke B json
s3browser-con upload prerelease.keybase.io  %GOPATH%\src\github.com\keybase\client\packaging\windows\%BUILD_TAG%\*.json prerelease.keybase.io/windows-support  || goto:build_error || EXIT /B 1
set smokeBSemVer=%KEYBASE_VERSION%
%GOPATH%\src\github.com\keybase\release\release announce-build --build-a="%SmokeASemVer%" --build-b="%smokeBSemVer%" --platform="windows" || goto:build_error || EXIT /B 1
%OUTPUT% "Successfully built Windows: --build-a=%SmokeASemVer% --build-b=%smokeBSemVer%
:no_smokeb

echo %ERRORLEVEL%

goto:eof

:checkout_keybase

if EXIST %GOPATH%\src\github.com\keybase\%~1 goto:repoexists
pushd %GOPATH%\src\github.com\keybase
git clone https://github.com/keybase/%~1.git
popd
:repoexists

pushd %GOPATH%\src\github.com\keybase\%~1
git pull origin %~2 || EXIT /B 1
git checkout %~2 || EXIT /B 1
popd
EXIT /B 0

goto:eof

:build_error
%OUTPUT% "Error building Windows"
EXIT /B 1

:check_ci
for /f %%i in ('git -C %GOPATH%\src\github.com\keybase\client rev-parse --short HEAD') do set clientCommit=%%i
for /f %%i in ('git -C %GOPATH%\src\github.com\keybase\kbfs rev-parse --short HEAD') do set kbfsCommit=%%i
echo [%clientCommit%] [%kbfsCommit%]
:: need GITHUB_TOKEN
pushd %GOPATH%\src\github.com\keybase\release
go build || goto:build_error || EXIT /B 1
release wait-ci --repo="client" --commit="%clientCommit%" --context="continuous-integration/jenkins/branch" --context="ci/circleci"  || goto:ci_error
release wait-ci --repo="kbfs" --commit="%kbfsCommit%" --context="continuous-integration/jenkins/branch" --context="ci/circleci"  || goto:ci_error
popd
EXIT /B 0

:ci_error
%OUTPUT% "CI Failure building Windows"
EXIT /B 1

Update dorelease.cmd

Update dorelease.cmd


set INCLUDE=%PREFIX%
"%PYTHON%" setup.py install
if errorlevel 1 exit 1

Update bld.bat

Update bld.bat


@echo off

rem https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=vs-2019

chcp 65001
rem code page 65001: Unicode (UTF-8)
rem code page 1250:  ANSI Central European; Central European (Windows)
rem code page 1251:  ANSI Cyrillic; Cyrillic (Windows)
rem code page 1252:  ANSI Latin 1; Western European (Windows)

set VSLANG=1033
rem msbuild locale 1033: English

rem read batch file arguments
set solution=%1
set architecture_compiler=%2
set architecture_target=%3
set configuration=%4

if [%solution%] == [] (
	echo provide a solution
	exit /b 0
)

if [%architecture_compiler%] == [] (
	echo provide architecture_compiler [x64, x86]
	exit /b 0
)

if [%architecture_target%] == [] (
	echo provide architecture_target [x64, x86, arm, arm64]
	exit /b 0
)

if [%configuration%] == [] (
	echo provide kind [Debug, Development, Shipping]
	exit /b 0
)

rem clean batch file arguments
set solution=%solution:"=%
set architecture_compiler=%architecture_compiler:"=%
set architecture_target=%architecture_target:"=%
set configuration=%configuration:"=%

rem pushd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build"
pushd "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build"
if %architecture_compiler% == %architecture_target% (
	call "vcvarsall.bat" %architecture_compiler%
) else (
	call "vcvarsall.bat" %architecture_compiler%_%architecture_target%
)
popd

echo ---- BUILD ---- %time%
msbuild %solution% -m -p:Configuration=%configuration%
echo ---- DONE ---- %time%

@echo off

rem https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=vs-2019

chcp 65001
rem code page 65001: Unicode (UTF-8)
rem code page 1250:  ANSI Central European; Central European (Windows)
rem code page 1251:  ANSI Cyrillic; Cyrillic (Windows)
rem code page 1252:  ANSI Latin 1; Western European (Windows)

set VSLANG=1033
rem msbuild locale 1033: English

rem read batch file arguments
set solution=%1
set architecture_compiler=%2
set architecture_target=%3
set configuration=%4

if [%solution%] == [] (
	echo provide a solution
	exit /b 0
)

if [%architecture_compiler%] == [] (
	echo provide architecture_compiler [x64, x86]
	exit /b 0
)

if [%architecture_target%] == [] (
	echo provide architecture_target [x64, x86, arm, arm64]
	exit /b 0
)

if [%configuration%] == [] (
	echo provide kind [Debug, Development, Shipping]
	exit /b 0
)

rem clean batch file arguments
set solution=%solution:"=%
set architecture_compiler=%architecture_compiler:"=%
set architecture_target=%architecture_target:"=%
set configuration=%configuration:"=%

rem pushd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build"
pushd "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build"
if %architecture_compiler% == %architecture_target% (
	call "vcvarsall.bat" %architecture_compiler%
) else (
	call "vcvarsall.bat" %architecture_compiler%_%architecture_target%
)
popd

set log_file=-fileLogger -fileLoggerParameters:Verbosity=normal;LogFile=bin-int/%configuration%.log;Encoding=UTF-8 -detailedSummary
set log_console=-noLogo -consoleLoggerParameters:Verbosity=quiet;Summary;ErrorsOnly;WarningsOnly
rem -consoleLoggerParameters:PerformanceSummary
rem verbosity: quiet, minimal, normal, detailed, diagnostic

echo ---- BUILD ---- %time%
msbuild %solution% -p:Configuration=%configuration% -maxCpuCount %log_console% %log_file%
echo ---- DONE ---- %time%

make console output smaller, but log into a file


@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem  Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windowz variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega

Create gradlew.bat

Create gradlew.bat


@echo off

goto entry

:usage
  echo usage: bolt test [-v^|--verbose] CONFIG TEST ...
  echo.
  echo arguments:
  echo   CONFIG                   The bolt configuration file to be used for tests
  echo   TEST                     A test file. The test file may contain one or more
  echo                            test methods. Test files have an `assert` library
  echo                            exposed to them automatically.
  echo.
  echo example:
  echo   Run all atomic tests.
  echo.
  echo     bolt test config/bolt/atomic.js src/test/js/atomic/**/*.js
  echo.
  echo.
  echo   Run all browser tests.
  echo.
  echo     bolt test config/bolt/browser.js src/test/js/browser/**/*.js

  exit /b 0

:fail_usage
  echo.
  call :usage
  exit /b 1

:fail
  exit /b 1

:is_dir
  setlocal
  set olddir=%CD%
  cd "%~1" 2>NUL
  set err=%errorlevel%
  cd "%olddir%"
  exit /b %err%

:entry

if "%help_mode%"=="true" call :usage && exit /b 0

set verbose=false

if "%~1"=="-v" (set verbose=true
  shift && goto done_flags)
if "%~1"=="--verbose" (set verbose=true
  shift && goto done_flags)

if "%~1"=="" goto done_flags

set flag=%~1
if "%flag:~0,1%"=="-" echo Unknown flag [%flag%] && goto fail_usage

:done_flags

if "%~2"=="" echo Not enough arguments, must specify configuration and at least one test file. && goto fail_usage

set config=%~1
shift

if not exist "%config%" echo Could not find config file [%config%] && exit /b 10
call :is_dir "%config%"
if %errorlevel%==0 echo Could not find config file [%config%] && exit /b 10

for %%i in (node.exe) do set node=%%~$PATH:i
if "%node%"=="" echo error: node.js is not on the system path && goto fail

set remaining=
:remaining
if "%~1"=="" goto end_remaining
set remaining=%remaining% "%~1"
shift
goto remaining
:end_remaining

setlocal enabledelayedexpansion
for %%i in (%remaining%) do (
  if not exist %%i echo Could not find test file [%%i] && exit /b 20
  call :is_dir %%i
  if !errorlevel!==0 echo Could not find test file [%%i] && exit /b 20)
endlocal

"%node%" "%base%bolt-test.js" "%verbose%" "%config%" %remaining%

@echo off

goto entry

:usage
  echo usage: bolt test [-v^|--verbose] CONFIG TEST ...
  echo.
  echo arguments:
  echo   CONFIG                   The bolt configuration file to be used for tests
  echo   TEST                     A test file. The test file may contain one or more
  echo                            test methods. Test files have an `assert` library
  echo                            exposed to them automatically.
  echo.
  echo example:
  echo   Run all atomic tests.
  echo.
  echo     bolt test config/bolt/atomic.js src/test/js/atomic/**/*.js
  echo.
  echo.
  echo   Run all browser tests.
  echo.
  echo     bolt test config/bolt/browser.js src/test/js/browser/**/*.js

  exit /b 0

:fail_usage
  echo.
  call :usage
  exit /b 1

:fail
  exit /b 1

:is_dir
  setlocal
  set olddir=%CD%
  cd "%~1" 2>NUL
  set err=%errorlevel%
  cd "%olddir%"
  exit /b %err%

:entry

if "%help_mode%"=="true" call :usage && exit /b 0

set verbose=false

if "%~1"=="-v" (set verbose=true
  shift && goto done_flags)
if "%~1"=="--verbose" (set verbose=true
  shift && goto done_flags)

if "%~1"=="" goto done_flags

set flag=%~1
if "%flag:~0,1%"=="-" echo Unknown flag [%flag%] && goto fail_usage

:done_flags

if "%~2"=="" echo Not enough arguments, must specify configuration and at least one test file. && goto fail_usage

set config=%~1
shift

if not exist "%config%" echo Could not find config file [%config%] && exit /b 10
call :is_dir "%config%"
if %errorlevel%==0 echo Could not find config file [%config%] && exit /b 10

for %%i in (node.exe) do set node=%%~$PATH:i
if "%node%"=="" echo error: node.js is not on the system path && goto fail

set remaining=
:remaining
if "%~1"=="" goto end_remaining
for /F "usebackq delims=" %%s in (`glob -w "%~1"`) do set globbed=%%s
set remaining=%remaining% %globbed%
shift
goto remaining
:end_remaining

setlocal enabledelayedexpansion
for %%i in (%remaining%) do (
  if not exist %%i echo Could not find test file [%%i] && exit /b 20
  call :is_dir %%i
  if !errorlevel!==0 echo Could not find test file [%%i] && exit /b 20)
endlocal

"%node%" "%base%bolt-test.js" "%verbose%" "%config%" %remaining%

Add globbing support for test file arguments passed into bolt test


@ECHO OFF

rem Change the current working directory to the location of this batch script.
pushd "%~dp0"
copy /Y mushclient_prefs.sqlite.sample mushclient_prefs.sqlite > nul
copy /Y MUSHclient.ini.sample MUSHclient.ini > nul
if not exist "worlds\mume\mume.mcl" copy /Y worlds\mume\mume.mcl.sample worlds\mume\mume.mcl > nul
if not exist "worlds\angband\angband.mcl" copy /Y worlds\angband\angband.mcl.sample worlds\angband\angband.mcl > nul
start MUSHclient.exe
cd mapperproxy
for %%x in (pypy.exe) do if not [%%~$PATH:x]==[] echo "Running mapper with PyPy." && pypy.exe -B startmapper.py raw && goto :finished
for %%x in (python.exe) do if not [%%~$PATH:x]==[] echo "Running mapper with Python." && python.exe -B startmapper.py raw && goto :finished
rem If we're here, Python wasn't found in the path.
echo "Error: Unable to locate Python!"
echo "This script requires that either PyPy or Python be installed and in the path."
pause
:finished
rem Reset the working directory to it's previous value, before this batch script was run.
popd

@ECHO OFF

rem Change the current working directory to the location of this batch script.
pushd "%~dp0"
copy /Y mushclient_prefs.sqlite.sample mushclient_prefs.sqlite > nul
copy /Y MUSHclient.ini.sample MUSHclient.ini > nul
if not exist "worlds\mume\mume.mcl" copy /Y worlds\mume\mume.mcl.sample worlds\mume\mume.mcl > nul
if not exist "worlds\angband\angband.mcl" copy /Y worlds\angband\angband.mcl.sample worlds\angband\angband.mcl > nul
start MUSHclient.exe
cd mapperproxy
for %%x in (pypy.exe) do (
	if not [%%~$PATH:x]==[] (
		echo "Running mapper with PyPy."
		pypy.exe -B startmapper.py raw
		goto :finished
	)
)
for %%x in (python.exe) do (
	if not [%%~$PATH:x]==[] (
		echo "Running mapper with Python."
		python.exe -B startmapper.py raw
		goto :finished
	)
)
rem If we're here, Python wasn't found in the path.
echo "Error: Unable to locate Python!"
echo "This script requires that either PyPy or Python be installed and in the path."
pause
:finished
rem Reset the working directory to it's previous value, before this batch script was run.
popd

Indent block statements inside mc.bat.

Indent block statements inside mc.bat.


@echo off
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "PersistBrowsers" /t REG_DWORD /d "1" /f
pause
exit

Create Set-PC.bat

Create Set-PC.bat


REM This script replaces the SDK folder with the latest bits from the Azure SDK repository.
REM It removes some files we do not need.  It currently targets the develop branch until fixes are
REM merged into master.

if exist "%~dp0\temp" rd /s /q "%~dp0\temp"
if exist "%~dp0\sdk" rd /s /q "%~dp0\sdk"

mkdir "%~dp0\temp"
mkdir "%~dp0\sdk"

cd /D "%~dp0\temp"

git clone https://github.com/Azure/azure-iot-sdks.git --recursive

cd "%~dp0\temp"

copy "%~dp0\temp\azure-iot-sdks\c\iothub_client\src\" "%~dp0\sdk"
copy "%~dp0\temp\azure-iot-sdks\c\iothub_client\inc\" "%~dp0\sdk"
copy "%~dp0\temp\azure-iot-sdks\c\serializer\src\" "%~dp0\sdk"
copy "%~dp0\temp\azure-iot-sdks\c\serializer\inc\" "%~dp0\sdk"
copy "%~dp0\temp\azure-iot-sdks\c\azure-c-shared-utility\c\src\" "%~dp0\sdk"
copy "%~dp0\temp\azure-iot-sdks\c\azure-c-shared-utility\c\inc\" "%~dp0\sdk"
copy "%~dp0\temp\azure-iot-sdks\c\azure-c-shared-utility\c\adapters\agenttime.c" "%~dp0\sdk"

del "%~dp0\sdk\iot_logging.h"
del "%~dp0\sdk\iothubtransportamqp.*"
del "%~dp0\sdk\iothubtransportamqp_websockets.*"
del "%~dp0\sdk\iothubtransportmqtt.*"
del "%~dp0\sdk\tickcounter.*"
del "%~dp0\sdk\tlsio*.*"
del "%~dp0\sdk\constbuffer.*"

cd ..

rmdir /S "%~dp0\temp"

REM This script replaces the SDK folder with the latest bits from the Azure SDK repository.
REM It removes some files we do not need.  It currently targets the develop branch until fixes are
REM merged into master.

if exist "%~dp0\temp" rd /s /q "%~dp0\temp"
if exist "%~dp0\sdk" rd /s /q "%~dp0\sdk"

mkdir "%~dp0\temp"
mkdir "%~dp0\sdk"

cd /D "%~dp0\temp"

git clone https://github.com/Azure/azure-iot-sdks.git --recursive

cd azure-iot-sdks
echo Upstream HEAD @ > metadata.txt
git rev-parse HEAD >> metadata.txt

cd "%~dp0\temp"

copy "%~dp0\temp\azure-iot-sdks\metadata.txt" "%~dp0\sdk"

copy "%~dp0\temp\azure-iot-sdks\c\iothub_client\src\" "%~dp0\sdk"
copy "%~dp0\temp\azure-iot-sdks\c\iothub_client\inc\" "%~dp0\sdk"
copy "%~dp0\temp\azure-iot-sdks\c\serializer\src\" "%~dp0\sdk"
copy "%~dp0\temp\azure-iot-sdks\c\serializer\inc\" "%~dp0\sdk"
copy "%~dp0\temp\azure-iot-sdks\c\azure-c-shared-utility\c\src\" "%~dp0\sdk"
copy "%~dp0\temp\azure-iot-sdks\c\azure-c-shared-utility\c\inc\" "%~dp0\sdk"
copy "%~dp0\temp\azure-iot-sdks\c\azure-c-shared-utility\c\adapters\agenttime.c" "%~dp0\sdk"

del "%~dp0\sdk\iot_logging.h"
del "%~dp0\sdk\iothubtransportamqp.*"
del "%~dp0\sdk\iothubtransportamqp_websockets.*"
del "%~dp0\sdk\iothubtransportmqtt.*"
del "%~dp0\sdk\tickcounter.*"
del "%~dp0\sdk\tlsio*.*"
del "%~dp0\sdk\constbuffer.*"

cd ..

rmdir /S "%~dp0\temp"

Save upstream commit hash when updating sdk


@ECHO OFF
rem -------------------------------------------------------------------------
rem  This script will run the client tests
rem
rem  To run this script:
rem       - To use the defaults, execute:  run.bat
rem       - Optional, pass parameters, execute:  run.bat  [scenarioname] [resultmode]
rem
rem       where - scenarioname can either reference the folder or .properties file for which scenario(s) to run
rem               this would need to include the full path to the folder or file
rem             - resultmode is either;  compare, generate, sql, none
rem
rem   compare:  compare actuals to expected results
rem   generate:  create new set of expected result files in the results directory
rem   none:   execute the queries, but no comparison is done
rem   sql:    create a query file containing a query for each table exposed in DatabaseMetaData
rem
rem
rem -------------------------------------------------------------------------

rem $Id$

@if not "%ECHO%" == ""  echo %ECHO%
@if "%OS%" == "Windows_NT" setlocal

if "%OS%" == "Windows_NT" (
  set "DIRNAME=%~dp0%"
) else (
  set DIRNAME=.\
)

rem ResultMode
set RMODE=sql

rem scenario file(s) location
set S_DIR=%DIRNAME%\tests\scenarios

rem host and port to connect to
set HOST=localhost
set PORT=31000

set OUTPUTDIR=%DIRNAME%\results
set CONFIG=%DIRNAME%\..\config\test.properties

rem set USERNAME=
rem set PASSWORD=
set EXECTIMEMIN=-1
set EXCEEDPERCENT=-1

rem if passing in sceario file
if not "%1"=="" (

set S_DIR=%1

)

rem if resultmode is passed in
if not "%2"=="" (

set RMODE=%2

)

ARGS=-Dscenario.file=%S_DIR%
ARGS=%ARGS% -Dqueryset.artifacts.dir=%QUERYSETDIR%
ARGS=%ARGS% -Dresult.mode=%RMODE%
ARGS=%ARGS% -Doutput.dir=%OUTPUTDIR%
ARGS=%ARGS% -Dconfig=%CONFIG%
ARGS=%ARGS% -Dhost.name=%HOST%
ARGS=%ARGS% -Dhost.port=%PORT%

ARGS=%ARGS% -Dexectimemin=%EXECTIMEMIN%
ARGS=%ARGS% -Dexceedpercent=%EXCEEDPERCENT%

rem If not set, the default to scenario or global properties
if "x%USERNAME%" == "x" (
  set  ARGS=%ARGS -Dusername=%USERNAME%
)

rem If not set, the default to scenario or global properties
if "x%PASSWORD%" == "x" (
  set  ARGS=%ARGS -Dpassword=%PASSWORD%
)

set CP=%DIRNAME%/lib/*;%DIRNAME%/config/*

java -cp %CP% %JAVA_OPTS% %ARGS% org.jboss.bqt.client.TestClient

add windows bat script file to execute the test


git submodule update --init --recursive

::build libuv
cd third-party\libuv
git checkout v1.10.1
start /b .\..\gyp\gyp.bat -I common.gypi --depth=. --generator-output=out --build=Release --build=Debug -Dhost_arch=x64 -Dtarget_arch=x64 -Duv_library=static_library -f msvs uv.gyp
start /b .\..\gyp\gyp.bat -I common.gypi --depth=. --generator-output=out --build=Release --build=Debug -Dhost_arch=x64 -Dtarget_arch=x64 -Duv_library=shared_library -f msvs uv.gyp
cd ..\..

.\make.bat

git submodule update --init --recursive

::build libuv
cd third-party\libuv
git checkout v1.10.1
start /b .\..\gyp\gyp.bat -I common.gypi --depth=. --generator-output=out --build=Release --build=Debug -Dhost_arch=x64 -Dtarget_arch=x64 -Duv_library=static_library -f msvs uv.gyp
sleep 60
start /b .\..\gyp\gyp.bat -I common.gypi --depth=. --generator-output=out --build=Release --build=Debug -Dhost_arch=x64 -Dtarget_arch=x64 -Duv_library=shared_library -f msvs uv.gyp
cd ..\..
sleep 60
.\make.bat

build on windows

build on windows


@echo off

if not defined PHP_SDK_RUN_FROM_ROOT (
	echo This script should not be run directly.
	echo Use starter scripts looking like phpsdk-^<crt^>-^<arch^>.bat in the PHP SDK root instead.
	goto out_error
)

if "%1"=="" goto :help
if "%1"=="/?" goto :help
if "%1"=="-h" goto :help
if "%1"=="--help" goto :help
if "%2"=="" goto :help

set PHP_SDK_VC=%1
if /i not "%PHP_SDK_VC:~0,2%"=="vc" (
:malformed_vc_string
	echo Malformed CRT string "%1"
	set PHP_SDK_VC=
	goto out_error
)
set /a TMP_CHK=%PHP_SDK_VC:~2,7%
if 14 gtr %TMP_CHK% (
	if "0"=="%TMP_CHK%" (
		if not "0"=="%PHP_SDK_VC:~2,7%" (
			set TMP_CHK=
			goto malformed_vc_string
		)
	)

	echo At least vc14 is required
	set PHP_SDK_VC=
	set TMP_CHK=
	goto out_error
)
set TMP_CHK=

if /i not "%2"=="x64" (
	if /i not "%2"=="x86" (
		echo Unsupported arch "%2"
		goto out_error
	)
)

set PHP_SDK_ARCH=%2

rem check OS arch
set TMPKEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion
reg query "%TMPKEY%" /v "ProgramFilesDir (x86)" >nul 2>nul
if not errorlevel 1 (
	set PHP_SDK_OS_ARCH=x64
) else (
	if /i "%PHP_SDK_ARCH%"=="x64" (
		echo 32-bit OS detected, native 64-bit toolchain is unavailable.
		goto out_error
	)
	set PHP_SDK_OS_ARCH=x86
)
set TMPKEY=

rem get vc base dir
if /i "%1"=="vc14" (
	if /i "%PHP_SDK_OS_ARCH%"=="x64" (
		set TMPKEY=HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%PHP_SDK_VC:~2%.0\Setup\VC
	) else (
		set TMPKEY=HKLM\SOFTWARE\Microsoft\VisualStudio\%PHP_SDK_VC:~2%.0\Setup\VC
	)
	reg query !TMPKEY! /v ProductDir >nul 2>&1
	if errorlevel 1 (
		echo Couldn't determine VC%PHP_SDK_VC:~2% directory
		goto out_error;
	)
	for /f "tokens=2*" %%a in ('reg query !TMPKEY! /v ProductDir') do set PHP_SDK_VC_DIR=%%b
) else (
	rem vc15 support only for now, could parse out and pass on later
	for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version %PHP_SDK_VC:~2,7% -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do set PHP_SDK_VC_DIR=%%b\VC
	set VSCMD_ARG_no_logo=nologo
)
set TMPKEY=

if /i "%PHP_SDK_VC%"=="vc14" (
	rem get sdk dir
	if /i "%PHP_SDK_OS_ARCH%"=="x64" (
		set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1
	) else (
		set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1
	)
	for /f "tokens=2*" %%a in ('reg query "!TMPKEY!" /v InstallationFolder') do (
		if exist "%%b\Include\um\Windows.h" (
			set PHP_SDK_WIN_SDK_DIR=%%b
		)
	)
	if not defined PHP_SDK_WIN_SDK_DIR (
		echo Windows SDK not found.
		goto out_error;
	)
	set TMPKEY=
)

if /i "%PHP_SDK_ARCH%"=="x64" (
	if /i "%1"=="vc14" (
		set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" amd64
	) else (
		set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" amd64
	)
) else (
	if /i "%1"=="vc14" (
		set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" x86
	) else (
		set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" x86
	)
)

rem echo Visual Studio path %PHP_SDK_VC_DIR%
rem echo Windows SDK path %PHP_SDK_WIN_SDK_DIR%

goto out

:help
	echo "Start Visual Studio command line for PHP SDK"
	echo "Usage: %0 vc arch"
	echo nul

:out_error
	exit /b 3

:out
rem	echo Shell configuration complete
	exit /b 0

goto :eof

@echo off

if not defined PHP_SDK_RUN_FROM_ROOT (
	echo This script should not be run directly.
	echo Use starter scripts looking like phpsdk-^<crt^>-^<arch^>.bat in the PHP SDK root instead.
	goto out_error
)

if "%1"=="" goto :help
if "%1"=="/?" goto :help
if "%1"=="-h" goto :help
if "%1"=="--help" goto :help
if "%2"=="" goto :help

set PHP_SDK_VC=%1
if /i not "%PHP_SDK_VC:~0,2%"=="vc" (
:malformed_vc_string
	echo Malformed CRT string "%1"
	set PHP_SDK_VC=
	goto out_error
)
if ""=="%PHP_SDK_VC:~2,2%" (
	goto malformed_vc_string
)
set /a TMP_CHK=%PHP_SDK_VC:~2,2%
if 14 gtr %TMP_CHK% (
	if "0"=="%TMP_CHK%" (
		if not "0"=="%PHP_SDK_VC:~2,2%" (
			set TMP_CHK=
			goto malformed_vc_string
		)
	)

	echo At least vc14 is required
	set PHP_SDK_VC=
	set TMP_CHK=
	goto out_error
)
set TMP_CHK=

if /i not "%2"=="x64" (
	if /i not "%2"=="x86" (
		echo Unsupported arch "%2"
		goto out_error
	)
)

set PHP_SDK_ARCH=%2

rem check OS arch
set TMPKEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion
reg query "%TMPKEY%" /v "ProgramFilesDir (x86)" >nul 2>nul
if not errorlevel 1 (
	set PHP_SDK_OS_ARCH=x64
) else (
	if /i "%PHP_SDK_ARCH%"=="x64" (
		echo 32-bit OS detected, native 64-bit toolchain is unavailable.
		goto out_error
	)
	set PHP_SDK_OS_ARCH=x86
)
set TMPKEY=

rem get vc base dir
if /i "%1"=="vc14" (
	if /i "%PHP_SDK_OS_ARCH%"=="x64" (
		set TMPKEY=HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%PHP_SDK_VC:~2%.0\Setup\VC
	) else (
		set TMPKEY=HKLM\SOFTWARE\Microsoft\VisualStudio\%PHP_SDK_VC:~2%.0\Setup\VC
	)
	reg query !TMPKEY! /v ProductDir >nul 2>&1
	if errorlevel 1 (
		echo Couldn't determine VC%PHP_SDK_VC:~2% directory
		goto out_error;
	)
	for /f "tokens=2*" %%a in ('reg query !TMPKEY! /v ProductDir') do set PHP_SDK_VC_DIR=%%b
) else (
	rem vc15 support only for now, could parse out and pass on later
	for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version %PHP_SDK_VC:~2,2% -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do set PHP_SDK_VC_DIR=%%b\VC
	set VSCMD_ARG_no_logo=nologo
)
set TMPKEY=

if /i "%PHP_SDK_VC%"=="vc14" (
	rem get sdk dir
	if /i "%PHP_SDK_OS_ARCH%"=="x64" (
		set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1
	) else (
		set TMPKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1
	)
	for /f "tokens=2*" %%a in ('reg query "!TMPKEY!" /v InstallationFolder') do (
		if exist "%%b\Include\um\Windows.h" (
			set PHP_SDK_WIN_SDK_DIR=%%b
		)
	)
	if not defined PHP_SDK_WIN_SDK_DIR (
		echo Windows SDK not found.
		goto out_error;
	)
	set TMPKEY=
)

if /i "%PHP_SDK_ARCH%"=="x64" (
	if /i "%1"=="vc14" (
		set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" amd64
	) else (
		set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" amd64
	)
) else (
	if /i "%1"=="vc14" (
		set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" x86
	) else (
		set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" x86
	)
)

rem echo Visual Studio path %PHP_SDK_VC_DIR%
rem echo Windows SDK path %PHP_SDK_WIN_SDK_DIR%

goto out

:help
	echo "Start Visual Studio command line for PHP SDK"
	echo "Usage: %0 vc arch"
	echo nul

:out_error
	exit /b 3

:out
rem	echo Shell configuration complete
	exit /b 0

goto :eof

improve crt version check

improve crt version check


@echo off
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)

for /f "delims=[] tokens=2" %%a in ('ping %computername% -n 1 ^| findstr "["') do (set thisip=%%a)

cscript /nologo %~dp0/wget.js "http://10.24.25.130:8000/log_this?username="+%USERNAME%+"&compname="+%computername%+"&stat=on&time="+%mydate%_%mytime%

@echo off
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)

cscript /nologo %~dp0/wget.js "http://10.24.25.130:8000/log_this?username="+%USERNAME%+"&compname="+%computername%+"&stat=on&time="+%mydate%_%mytime%

Update login.bat

Update login.bat

ip address not used in the API. So removing it.


@echo off
REM Copyright (c) 2016-2019 Vegard IT GmbH, https://vegardit.com
REM SPDX-License-Identifier: Apache-2.0
REM Author: Sebastian Thomschke, Vegard IT GmbH

call %~dp0_test-prepare.cmd java hxjava

echo Compiling...
haxe %~dp0..\tests.hxml -D jvm -java target\java
set rc=%errorlevel%
popd
if not %rc% == 0 exit /b %rc%

echo Testing...
java -jar "%~dp0..\target\java\TestRunner-Debug.jar"

add jvm target test

add jvm target test


@rem ===========================================================================================================
@rem Copyright (c) Microsoft Corporation.  All Rights Reserved.  Licensed under the Apache License,
@rem               Version 2.0.  See License.txt in the project root for license information.
@rem ===========================================================================================================

@echo off
setlocal

if /i "%1" == "debug" goto :ok
if /i "%1" == "release" goto :ok
if /i "%1" == "signonly" goto :ok

echo adding required strong name verification skipping, and NGening built binaries
echo Usage:
echo    update.cmd debug   [-ngen]
echo    update.cmd release [-ngen]
exit /b 1

:ok

set BINDIR=%~dp0..\%1\net40\bin

if /i "%PROCESSOR_ARCHITECTURE%"=="x86" set X86_PROGRAMFILES=%ProgramFiles%
if /I "%PROCESSOR_ARCHITECTURE%"=="AMD64" set X86_PROGRAMFILES=%ProgramFiles(x86)%

set REGEXE32BIT=reg.exe
if not "%OSARCH%"=="x86" set REGEXE32BIT=%WINDIR%\syswow64\reg.exe

                            FOR /F "tokens=2* delims=	 " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\NETFXSDK\4.6\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS=%%B
if "%WINSDKNETFXTOOLS%"=="" FOR /F "tokens=2* delims=	 " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\Windows\v8.1A\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS=%%B
if "%WINSDKNETFXTOOLS%"=="" FOR /F "tokens=2* delims=	 " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS=%%B
if "%WINSDKNETFXTOOLS%"=="" FOR /F "tokens=2* delims=	 " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\Windows\v7.1\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS=%%B
if "%WINSDKNETFXTOOLS%"=="" FOR /F "tokens=2* delims=	 " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS=%%B

set SN32="%WINSDKNETFXTOOLS%sn.exe"
set SN64="%WINSDKNETFXTOOLS%x64\sn.exe"
set NGEN32=%windir%\Microsoft.NET\Framework\v4.0.30319\ngen.exe
set NGEN64=%windir%\Microsoft.NET\Framework64\v4.0.30319\ngen.exe

rem Disable strong-name validation for F# binaries built from open source that are signed with the microsoft key
%SN32% -Vr FSharp.Core,b03f5f7f11d50a3a
%SN32% -Vr FSharp.Build,b03f5f7f11d50a3a
%SN32% -Vr FSharp.Compiler.Interactive.Settings,b03f5f7f11d50a3a
%SN32% -Vr FSharp.Compiler.Hosted,b03f5f7f11d50a3a

%SN32% -Vr fsc,b03f5f7f11d50a3a
%SN32% -Vr fsi,b03f5f7f11d50a3a
%SN32% -Vr FsiAnyCPU,b03f5f7f11d50a3a

%SN32% -Vr FSharp.Compiler,b03f5f7f11d50a3a
%SN32% -Vr FSharp.Compiler.Server.Shared,b03f5f7f11d50a3a
%SN32% -Vr FSharp.Editor,b03f5f7f11d50a3a
%SN32% -Vr FSharp.LanguageService,b03f5f7f11d50a3a
%SN32% -Vr FSharp.LanguageService.Base,b03f5f7f11d50a3a
%SN32% -Vr FSharp.LanguageService.Compiler,b03f5f7f11d50a3a
%SN32% -Vr FSharp.ProjectSystem.Base,b03f5f7f11d50a3a
%SN32% -Vr FSharp.ProjectSystem.FSharp,b03f5f7f11d50a3a
%SN32% -Vr FSharp.ProjectSystem.PropertyPages,b03f5f7f11d50a3a
%SN32% -Vr FSharp.VS.FSI,b03f5f7f11d50a3a
%SN32% -Vr VisualFSharp.Unittests,b03f5f7f11d50a3a
%SN32% -Vr VisualFSharp.Salsa,b03f5f7f11d50a3a
%SN32% -Vr FSharp.Compiler.Unittests,b03f5f7f11d50a3a

if /i "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
    %SN64% -Vr FSharp.Core,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.Build,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.Compiler.Interactive.Settings,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.Compiler.Hosted,b03f5f7f11d50a3a

    %SN64% -Vr fsc,b03f5f7f11d50a3a
    %SN64% -Vr fsi,b03f5f7f11d50a3a
    %SN64% -Vr FsiAnyCPU,b03f5f7f11d50a3a

    %SN64% -Vr FSharp.Compiler,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.Compiler.Server.Shared,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.Editor,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.LanguageService,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.LanguageService.Base,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.LanguageService.Compiler,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.ProjectSystem.Base,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.ProjectSystem.FSharp,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.ProjectSystem.PropertyPages,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.VS.FSI,b03f5f7f11d50a3a
    %SN64% -Vr VisualFSharp.Unittests,b03f5f7f11d50a3a
    %SN64% -Vr VisualFSharp.Salsa,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.Compiler.Unittests,b03f5f7f11d50a3a
)

if /i '%1' == 'signonly' goto :eof
if /i '%1' == 'debug' set NGEN_FLAGS=/Debug

rem NGen fsc, fsi, fsiAnyCpu, and FSharp.Build.dll
if /i not "%2"=="-ngen" goto :donengen

"%NGEN32%" install "%BINDIR%\fsc.exe" %NGEN_FLAGS% /queue:1
"%NGEN32%" install "%BINDIR%\fsi.exe" %NGEN_FLAGS% /queue:1
"%NGEN32%" install "%BINDIR%\FSharp.Build.dll" %NGEN_FLAGS% /queue:1
"%NGEN32%" executeQueuedItems 1

if /i "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
    "%NGEN64%" install "%BINDIR%\fsiAnyCpu.exe" /queue:1
    "%NGEN64%" install "%BINDIR%\FSharp.Build.dll" /queue:1
    "%NGEN64%" executeQueuedItems 1
)

:donengen

@rem ===========================================================================================================
@rem Copyright (c) Microsoft Corporation.  All Rights Reserved.  Licensed under the Apache License,
@rem               Version 2.0.  See License.txt in the project root for license information.
@rem ===========================================================================================================

@echo off
setlocal

if /i "%1" == "debug" goto :ok
if /i "%1" == "release" goto :ok
if /i "%1" == "signonly" goto :ok

echo adding required strong name verification skipping, and NGening built binaries
echo Usage:
echo    update.cmd debug   [-ngen]
echo    update.cmd release [-ngen]
exit /b 1

:ok

set BINDIR=%~dp0..\%1\net40\bin

if /i "%PROCESSOR_ARCHITECTURE%"=="x86" set X86_PROGRAMFILES=%ProgramFiles%
if /I "%PROCESSOR_ARCHITECTURE%"=="AMD64" set X86_PROGRAMFILES=%ProgramFiles(x86)%

set REGEXE32BIT=reg.exe
if not "%OSARCH%"=="x86" set REGEXE32BIT=%WINDIR%\syswow64\reg.exe

                            FOR /F "tokens=2* delims=	 " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\NETFXSDK\4.6\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS=%%B
if "%WINSDKNETFXTOOLS%"=="" FOR /F "tokens=2* delims=	 " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\Windows\v8.1A\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS=%%B
if "%WINSDKNETFXTOOLS%"=="" FOR /F "tokens=2* delims=	 " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS=%%B
if "%WINSDKNETFXTOOLS%"=="" FOR /F "tokens=2* delims=	 " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\Windows\v7.1\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS=%%B
if "%WINSDKNETFXTOOLS%"=="" FOR /F "tokens=2* delims=	 " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS=%%B

set SN32="%WINSDKNETFXTOOLS%sn.exe"
set SN64="%WINSDKNETFXTOOLS%x64\sn.exe"
set NGEN32=%windir%\Microsoft.NET\Framework\v4.0.30319\ngen.exe
set NGEN64=%windir%\Microsoft.NET\Framework64\v4.0.30319\ngen.exe

rem Disable strong-name validation for F# binaries built from open source that are signed with the microsoft key
%SN32% -Vr FSharp.Core,b03f5f7f11d50a3a
%SN32% -Vr FSharp.Build,b03f5f7f11d50a3a
%SN32% -Vr FSharp.Compiler.Interactive.Settings,b03f5f7f11d50a3a
%SN32% -Vr FSharp.Compiler.Hosted,b03f5f7f11d50a3a

%SN32% -Vr fsc,b03f5f7f11d50a3a
%SN32% -Vr fsi,b03f5f7f11d50a3a
%SN32% -Vr FsiAnyCPU,b03f5f7f11d50a3a

%SN32% -Vr FSharp.Compiler,b03f5f7f11d50a3a
%SN32% -Vr FSharp.Compiler.Server.Shared,b03f5f7f11d50a3a
%SN32% -Vr FSharp.Editor,b03f5f7f11d50a3a
%SN32% -Vr FSharp.LanguageService,b03f5f7f11d50a3a
%SN32% -Vr FSharp.LanguageService.Base,b03f5f7f11d50a3a
%SN32% -Vr FSharp.LanguageService.Compiler,b03f5f7f11d50a3a
%SN32% -Vr FSharp.ProjectSystem.Base,b03f5f7f11d50a3a
%SN32% -Vr FSharp.ProjectSystem.FSharp,b03f5f7f11d50a3a
%SN32% -Vr FSharp.ProjectSystem.PropertyPages,b03f5f7f11d50a3a
%SN32% -Vr FSharp.VS.FSI,b03f5f7f11d50a3a
%SN32% -Vr VisualFSharp.Unittests,b03f5f7f11d50a3a
%SN32% -Vr VisualFSharp.Salsa,b03f5f7f11d50a3a
%SN32% -Vr FSharp.Compiler.Unittests,b03f5f7f11d50a3a

if /i "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
    %SN64% -Vr FSharp.Core,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.Build,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.Compiler.Interactive.Settings,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.Compiler.Hosted,b03f5f7f11d50a3a

    %SN64% -Vr fsc,b03f5f7f11d50a3a
    %SN64% -Vr fsi,b03f5f7f11d50a3a
    %SN64% -Vr FsiAnyCPU,b03f5f7f11d50a3a

    %SN64% -Vr FSharp.Compiler,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.Compiler.Server.Shared,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.Editor,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.LanguageService,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.LanguageService.Base,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.LanguageService.Compiler,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.ProjectSystem.Base,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.ProjectSystem.FSharp,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.ProjectSystem.PropertyPages,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.VS.FSI,b03f5f7f11d50a3a
    %SN64% -Vr VisualFSharp.Unittests,b03f5f7f11d50a3a
    %SN64% -Vr VisualFSharp.Salsa,b03f5f7f11d50a3a
    %SN64% -Vr FSharp.Compiler.Unittests,b03f5f7f11d50a3a
)

if /i '%1' == 'signonly' goto :eof
if /i '%1' == 'debug' set NGEN_FLAGS=/Debug

rem NGen fsc, fsi, fsiAnyCpu, and FSharp.Build.dll
if /i not "%2"=="-ngen" goto :donengen

"%NGEN32%" install "%BINDIR%\fsc.exe" %NGEN_FLAGS% /queue:1
"%NGEN32%" install "%BINDIR%\fsi.exe" %NGEN_FLAGS% /queue:1
"%NGEN32%" install "%BINDIR%\FSharp.Build.dll" %NGEN_FLAGS% /queue:1
"%NGEN32%" executeQueuedItems 1

if /i "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
    "%NGEN64%" install "%BINDIR%\fsiAnyCpu.exe" %NGEN_FLAGS% /queue:1
    "%NGEN64%" install "%BINDIR%\FSharp.Build.dll" %NGEN_FLAGS% /queue:1
    "%NGEN64%" executeQueuedItems 1
)

:donengen

update debug flags for 64-bit ngen

update debug flags for 64-bit ngen


@echo off
cls
if not exist tools\FAKE\tools\Fake.exe (
  src\.nuget\nuget.exe install FAKE -OutputDirectory tools -ExcludeVersion -Prerelease
)
tools\FAKE\tools\Fake.exe build.fsx %* Release "logfile=build-log.xml"
rem tools\FAKE\tools\Fake.exe build.fsx %* Release "nugetkey=invalidaccesskey" "logfile=build-log.xml"
pause

Create publish.bat

Create publish.bat


@echo off
setlocal
set mypath=%~dp0
set PATH=%mypath%\python2.7;%PATH%
set PYTHONPATH=%mypath%\lib
set OQ_SITE_CFG_PATH=%mypath%\openquake.cfg
set OQ_HOST=127.0.0.1
set OQ_PORT=8800

echo Please wait ...
REM Start the WebUI using django
start "OpenQuake WebUI server" /B python.exe -m openquake.commands webui start %OQ_HOST%:%OQ_PORT%

REM Make sure that the dbserver is up and running
call:check_django

REM Start the browser
start http://localhost:%OQ_PORT%

endlocal
exit /b 0

:check_django
setlocal
ping -n 1 %OQ_HOST
if ERRORLEVEL 1
    goto check_django
endlocal

:sleep
setlocal
if exist C:\Windows\System32\timeout.exe (
    timeout /t %~1 /nobreak > NUL
) else (
    REM Windows XP hack
    ping 192.0.2.2 -n %~1 -w 1000 > NUL
)
endlocal

@echo off
setlocal
set mypath=%~dp0
set PATH=%mypath%\python2.7;%PATH%
set PYTHONPATH=%mypath%\lib
set OQ_SITE_CFG_PATH=%mypath%\openquake.cfg
set OQ_HOST=127.0.0.1
set OQ_PORT=8800

echo Please wait ...
REM Start the WebUI using django
start "OpenQuake WebUI server" /B python.exe -m openquake.commands webui start %OQ_HOST%:%OQ_PORT%

REM Make sure that the dbserver is up and running
call:sleep 10

REM Start the browser
start http://localhost:%OQ_PORT%

endlocal
exit /b 0

:sleep
setlocal
if exist C:\Windows\System32\timeout.exe (
    timeout /t %~1 /nobreak > NUL
) else (
    REM Windows XP hack
    ping 192.0.2.2 -n %~1 -w 1000 > NUL
)
endlocal

Revert to sleep in oq-webui.bat

Revert to sleep in oq-webui.bat


setlocal EnableDelayedExpansion

echo ON

if "%CONDA_VERSION%"=="" set CONDA_VERSION=2
if "%CONDA_DIR%"=="" set CONDA_DIR='%USERPROFILE%\Miniconda!CONDA_VERSION!'

if "%PLATFORM%"=="" set PLATFORM=%PROCESSOR_ARCHITECTURE%
if not "!PLATFORM!"=="x86" set PLATFORM=x86_64

where curl
if !ERRORLEVEL! neq 0 (
    echo "You must first install the cURL program"
    exit /b !ERRORLEVEL!
)

if not exist %CONDA_DIR% (
    curl https://repo.continuum.io/miniconda/Miniconda%CONDA_VERSION%-latest-Windows-%PLATFORM%.exe -o miniconda.exe
    if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
    start /wait "" miniconda.exe /InstallationType=JustMe /RegisterPython=0 /S /D=%CONDA_DIR%
    if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
    del miniconda.exe
    if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
)

set PATH=%CONDA_DIR%;%CONDA_DIR%\Scripts;%PATH%

if [[ "$CONDA_ALWAYS_YES" = "" ]]; then
  CONDA_ALWAYS_YES=no
fi
if [[ "$CONDA_CHANGE_PS1" = "" ]]; then
  CONDA_CHANGE_PS1=yes
fi
conda config --set always_yes $CONDA_ALWAYS_YES
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
conda config --set changeps1 $CONDA_CHANGE_PS1
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
conda update -q conda
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!

echo OFF

setlocal EnableDelayedExpansion

echo ON

if "%CONDA_VERSION%"=="" set CONDA_VERSION=2
if "%CONDA_DIR%"=="" set CONDA_DIR=%USERPROFILE%\Miniconda!CONDA_VERSION!

if "%PLATFORM%"=="" set PLATFORM=%PROCESSOR_ARCHITECTURE%
if not "!PLATFORM!"=="x86" set PLATFORM=x86_64

where curl
if !ERRORLEVEL! neq 0 (
    echo "You must first install the cURL program"
    exit /b !ERRORLEVEL!
)

if not exist!CONDA_DIR! (
    curl https://repo.continuum.io/miniconda/Miniconda!CONDA_VERSION!-latest-Windows-!PLATFORM!.exe -o miniconda.exe
    if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
    start /wait "" miniconda.exe /InstallationType=JustMe /RegisterPython=0 /S /D=!CONDA_DIR!
    if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
    del miniconda.exe
    if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
)

attrib +h !CONDA_DIR!
if !ERRORLEVEL! neq 0 echo Failed to hide the !CONDA_DIR! directory

set PATH=!CONDA_DIR!;!CONDA_DIR!\Scripts;%PATH%

if "%CONDA_ALWAYS_YES%"=="" set CONDA_ALWAYS_YES=no
if "%CONDA_CHANGE_PS1%"=="" set CONDA_CHANGE_PS1=yes

conda config --set always_yes !CONDA_ALWAYS_YES!
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
conda config --set changeps1 !CONDA_CHANGE_PS1!
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
conda update -q conda
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!

echo OFF

Update install.bat

Update install.bat


set JAVA_HOME="C:\Program Files\Java\jdk11"
call ..\gradlew clean installDist
call "C:\Program Files\Java\jdk11\bin\jlink.exe" --verbose --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules java.base,java.desktop,java.logging,java.management,java.naming,java.sql,java.xml,jdk.unsupported --output build\install\plus-f\runtime
call "C:\Program Files (x86)\Inno Setup 5\iscc.exe" package\windows\plus-f.iss /Obuild /FPlus-F
call aws s3 cp build/Plus-F.exe s3://download.socialthingy.com/Plus-F.exe

Set JAVA_HOME for Windows builds

Set JAVA_HOME for Windows builds


@echo off

setlocal
rem -----------------------------------------------
rem is batch executing with adiMistrator privileges
rem
rem -----------------------------------------------
set filename=%windir%\$%random%$
(@echo Hello, this is the administrator >%filename% ) 2> nul && (del %filename% & set elevated=1) || (set elevated=0)
if %elevated% == 0 (
    echo This script requires an elevated command shell to run.
    echo finished
    goto :eof
    )

if "%targetVS%"=="" set targetVS=12.0
if "%targetHive%"=="" set targetHive=Roslyn

set PreviewVersion=0.6.40308.1
set unconfigure=false
set verification=-Vr
set label=Disable

echo Prepare for Roslyn Open Source development
echo.

echo Create or clean the RoslynDev addin hive
echo.

if "%VSSDK120Install%" == "" (
    echo ERROR!   To build and debug the .Net compilers Open source projects requires the latest Visual Studio SDK.
    echo.
    set errorlevel=1
    goto :eof
    )

if /I "%1"=="u" (
    set unconfigure=true
    set verification=-Vu
    set label=Enable
    )

if not "%unconfigure%" == "true" (
    set unconfigure=false
    set verification=-Vr
    set label=Disable
    )

if not "%unconfigure%" == "true" (
    "%VSSDK120Install%\VisualStudioIntegration\Tools\Bin\CreateExpInstance.exe" /Reset /VSInstance=%targetVS% /RootSuffix=%TargetHive%  2> nul

	msbuild %~dp0\prepare.msbuild
    )

call :DisableVerificationFor Microsoft.CodeAnalysis.dll
call :DisableVerificationFor Microsoft.CodeAnalysis.CSharp.dll
call :DisableVerificationFor Microsoft.CodeAnalysis.VisualBasic.dll
call :DisableVerificationFor Microsoft.CodeAnalysis.Workspaces.dll
call :DisableVerificationFor Microsoft.CodeAnalysis.CSharp.Workspaces.dll
call :DisableVerificationFor Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll
call :DisableVerificationFor Microsoft.CodeAnalysis.FxCopAnalyzers.dll
call :DisableVerificationFor Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers.dll
call :DisableVerificationFor Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers.dll
call :DisableVerificationFor CompilerPackage.dll
call :DisableVerificationFor FxCopRulesSetup.dll
call :DisableVerificationFor Roslyn.Compilers.BuildTasks.dll
call :DisableVerificationFor rcsc.exe
call :DisableVerificationFor rvbc.exe
call :DisableVerificationFor VBCSCompiler.exe

rem List skip verification entries
echo.
sn -q -Vl

if "%unconfigure%" == "true" (
    rem Reset the RoslynDev hive from the main hive,
    "%VSSDK120Install%\VisualStudioIntegration\Tools\Bin\CreateExpInstance.exe" /Clean /VSInstance=%targetVS% /RootSuffix=%TargetHive%  2> nul
    reg delete HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\%targetVS%%TargetHive% /F > nul 2>&1
    reg delete HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\%targetVS%%TargetHive%_Config /F > nul 2>&1
    )

goto :eof

:DisableVerificationFor %1
@echo %label% verification for %1
for /F %%f in ('dir /s /b "%LOCALAPPDATA%\Microsoft\VisualStudio\%targetVS%%TargetHive%\%1"') do sn -q %verification% "%%f" && goto :eof
goto :eof

@echo off

setlocal
rem -----------------------------------------------
rem is batch executing with adiMistrator privileges
rem
rem -----------------------------------------------
set filename=%windir%\$%random%$
(@echo Hello, this is the administrator >%filename% ) 2> nul && (del %filename% & set elevated=1) || (set elevated=0)
if %elevated% == 0 (
    echo This script requires an elevated command shell to run.
    echo finished
    goto :eof
    )

if "%targetVS%"=="" set targetVS=12.0
if "%targetHive%"=="" set targetHive=Roslyn

set PreviewVersion=0.6.40308.1
set unconfigure=false
set verification=-Vr
set label=Disable

echo Prepare for Roslyn Open Source development
echo.

echo Create or clean the RoslynDev addin hive
echo.

if "%VSSDK120Install%" == "" (
    echo ERROR!   To build and debug the .Net compilers Open source projects requires the latest Visual Studio SDK.
    echo.
    set errorlevel=1
    goto :eof
    )

if /I "%1"=="u" (
    set unconfigure=true
    set verification=-Vu
    set label=Enable
    )

if not "%unconfigure%" == "true" (
    set unconfigure=false
    set verification=-Vr
    set label=Disable
    )

if not "%unconfigure%" == "true" (
    "%VSSDK120Install%\VisualStudioIntegration\Tools\Bin\CreateExpInstance.exe" /Reset /VSInstance=%targetVS% /RootSuffix=%TargetHive%  2> nul

    msbuild %~dp0\prepare.msbuild
    )

call :DisableVerificationFor "Microsoft.CodeAnalysis,31BF3856AD364E35"
call :DisableVerificationFor "Microsoft.CodeAnalysis.CSharp,31BF3856AD364E35"
call :DisableVerificationFor "Microsoft.CodeAnalysis.VisualBasic,31BF3856AD364E35"
call :DisableVerificationFor "Microsoft.CodeAnalysis.Workspaces,31BF3856AD364E35"
call :DisableVerificationFor "Microsoft.CodeAnalysis.CSharp.Workspaces,31BF3856AD364E35"
call :DisableVerificationFor "Microsoft.CodeAnalysis.VisualBasic.Workspaces,31BF3856AD364E35"
call :DisableVerificationFor "Microsoft.CodeAnalysis.FxCopAnalyzers,31BF3856AD364E35"
call :DisableVerificationFor "Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers,31BF3856AD364E35"
call :DisableVerificationFor "Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers,31BF3856AD364E35"
call :DisableVerificationFor "CompilerPackage,31BF3856AD364E35"
call :DisableVerificationFor "FxCopRulesSetup,31BF3856AD364E35"
call :DisableVerificationFor "Roslyn.Compilers.BuildTasks,31BF3856AD364E35"
call :DisableVerificationFor "rcsc,31BF3856AD364E35"
call :DisableVerificationFor "rvbc,31BF3856AD364E35"
call :DisableVerificationFor "VBCSCompiler,31BF3856AD364E35"

rem List skip verification entries
echo.
if exist "%WindowsSDK_ExecutablePath_x86%"sn.exe echo. && echo x86 verification Entries && "%WindowsSDK_ExecutablePath_x86%sn.exe" -q  -Vl
if exist "%WindowsSDK_ExecutablePath_x64%"sn.exe echo. && echo x64 verification Entries && "%WindowsSDK_ExecutablePath_x64%sn.exe" -q  -Vl
echo.

if "%unconfigure%" == "true" (
    rem Reset the RoslynDev hive from the main hive,
    "%VSSDK120Install%\VisualStudioIntegration\Tools\Bin\CreateExpInstance.exe" /Clean /VSInstance=%targetVS% /RootSuffix=%TargetHive%  2> nul
    reg delete HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\%targetVS%%TargetHive% /F > nul 2>&1
    reg delete HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\%targetVS%%TargetHive%_Config /F > nul 2>&1
    )

goto :eof

:DisableVerificationFor %1
@echo %label% verification for %1
if exist "%WindowsSDK_ExecutablePath_x86%"sn.exe "%WindowsSDK_ExecutablePath_x86%sn.exe" -q  %verification% %1
if exist "%WindowsSDK_ExecutablePath_x64%"sn.exe "%WindowsSDK_ExecutablePath_x64%sn.exe" -q  %verification% %1

Fix strong name verification disabling

Fix strong name verification disabling

1. Explicitly specify assembly name and key, instead of looking for it.
2. Port change 1220400 to preview branch to operate on 64-bit assemblies as well. (changeset 1221395)


;= echo off
;= rem Call DOSKEY and use this file as the macrofile
;= %SystemRoot%\system32\doskey /listsize=1000 /macrofile=%0%
;= rem In batch mode, jump to the end of the file
;= goto:eof
;= Add aliases below here

clear=cls
cmderr=cd /d "%CMDER_ROOT%"
e.=explorer .
gvim="C:\Program Files (x86)\Vim\vim80\gvim.exe" $*
history=cat "%CMDER_ROOT%\config\.history"
ll=ls -l -h --show-control-chars -F --color $*
ls=ls --show-control-chars -F --color $*
nuget="C:\workspace\nuget\nuget.exe" $*
pip2="C:\Program Files\Anaconda2\Scripts\pip.exe" $*
pip3="C:\Program Files\Anaconda3\Scripts\pip.exe" $*
pwd=cd
unalias=alias /d $1
vi=vim $*
vim="C:\Program Files (x86)\Vim\vim80\vim.exe" $*
vimdiff="C:\Program Files (x86)\Vim\vim80\vim.exe" -d $*
vsdevcmd="C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat"
vsmsbuild="C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsMSBuildCmd.bat"

;= Git
g=git $*

;= Git Add
ga=git add --verbose $*
gae=git add --verbose --edit $*
gad=git add --verbose --interactive $*
gap=git add --verbose --patch $*
gau=git add --verbose --update $*

;= Git Branch
gb=git branch -vv $*
gba=git branch -vv --all $*
gbc=git checkout -b $*
gbd=git branch --delete $*
gbm=git branch --move $*
gbs=git show-branch $*

;= Git Commit
gc=git commit -v $*
gca=git commit -v --all $*
gcF=git commit -v --amend $*
gcm=git commit --message $*
gcp=git cherry-pick --ff $*
gcS=git commit --gpg-sign $*
gcSF=git commit --amend --gpg-sign $*
gco=git checkout $*
gcs=git show $*

;= Git Diff
gd=git diff $*
gdc=git diff --cached $*

;= Git Fetch
gf=git fetch --all --tags --prune $*
gfc=git clone $*
gfcr=git clone --recurse-submodules $*
gfm=git pull
gfr=git pull --rebase
gfx="C:\workspace\aliases\gfx.cmd" $*
gfu=git remote --verbose update --prune $*

;= Git Grep
gg=git grep $*
ggi=git grep --interactive $*
ggl=git grep --files-with-matches $*
ggv=git grep --invert-match $*
ggw=git grep --word-regexp $*

;= Git Index
gia=git add $*
gid=git diff --cached $*
gir=git reset $*

;= Git Log Author
gl=git log --topo-order --pretty=format:"%C(4)%aN %C(7)<%aE> %C(4)%ar %C(3)%ad %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" $*
gla=git log --topo-order --pretty=format:"%C(4)%aN %C(7)<%aE> %C(4)%ar %C(3)%ad %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --all $*
glag=git log --topo-order --pretty=format:"%C(4)%aN %C(7)<%aE> %C(4)%ar %C(3)%ad %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --all --graph $*
gld=git log --topo-order --pretty=format:"%C(4)%aN %C(7)<%aE> %C(4)%ar %C(3)%ad %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --no-merges --first-parent $*
gldp=git log --topo-order --pretty=format:"%C(4)%aN %C(7)<%aE> %C(4)%ar %C(3)%ad %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --no-merges --first-parent --patch $*
glg=git log --topo-order --pretty=format:"%C(4)%aN %C(7)<%aE> %C(4)%ar %C(3)%ad %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --graph $*

;= Git Log Committer
glc=git log --topo-order --pretty=format:"%C(4)%cN %C(7)<%cE> %C(4)%cr %C(3)%cd %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" $*
glca=git log --topo-order --pretty=format:"%C(4)%cN %C(7)<%cE> %C(4)%cr %C(3)%cd %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --all $*
glcag=git log --topo-order --pretty=format:"%C(4)%cN %C(7)<%cE> %C(4)%cr %C(3)%cd %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --all --graph $*
glcd=git log --topo-order --pretty=format:"%C(4)%cN %C(7)<%cE> %C(4)%cr %C(3)%cd %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --no-merges --first-parent $*
glcdp=git log --topo-order --pretty=format:"%C(4)%cN %C(7)<%cE> %C(4)%cr %C(3)%cd %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --no-merges --first-parent --patch $*
glcg=git log --topo-order --pretty=format:"%C(4)%cN %C(7)<%cE> %C(4)%cr %C(3)%cd %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --graph $*

gls=git log --topo-order --stat --pretty=format:"${_git_log_medium_format}" $*

;= Git Merge
gm=git merge $*
gma=git merge --abort $*
gmt=git mergetool $*

;= Git Push
gp=git push $*
gpt=git push --tags $*

;= Git Rebase
gr=git rebase $*
gra=git rebase --abort $*
grc=git rebase --continue $*
gri=git rebase --interactive $*

;= Git Remote

;= Git Stash
gs=git stash $*
gsa=git stash apply $*
gsd=git stash show --patch --stat $*
gsx=git stash drop $*
gsl=git stash list $*
gsp=git stash pop $*
gss=git stash save --include-untracked $*

;= Git Working Copy
gwa=git add --verbose $*
gws=git status $*
gwd=git diff $*
gwr=git reset --soft $*
gwc=git clean $*

;= echo off
;= rem Call DOSKEY and use this file as the macrofile
;= %SystemRoot%\system32\doskey /listsize=1000 /macrofile=%0%
;= rem In batch mode, jump to the end of the file
;= goto:eof
;= Add aliases below here

clear=cls
cmderr=cd /d "%CMDER_ROOT%"
e.=explorer .
history=cat "%CMDER_ROOT%\config\.history"
ll=ls -l -h --show-control-chars -F --color $*
ls=ls --show-control-chars -F --color $*
nuget="C:\workspace\nuget\nuget.exe" $*
pip2="C:\Program Files\Anaconda2\Scripts\pip.exe" $*
pip3="C:\Program Files\Anaconda3\Scripts\pip.exe" $*
pwd=cd
unalias=alias /d $1
vi=vim $*
vim="C:\Program Files (x86)\Vim\vim80\vim.exe" $*
vimdiff="C:\Program Files (x86)\Vim\vim80\vim.exe" -d $*
vsdevcmd="C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat"
vsmsbuild="C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsMSBuildCmd.bat"

;= Git
g=git $*

;= Git Add
ga=git add --verbose $*
gae=git add --verbose --edit $*
gad=git add --verbose --interactive $*
gap=git add --verbose --patch $*
gau=git add --verbose --update $*

;= Git Branch
gb=git branch -vv $*
gba=git branch -vv --all $*
gbc=git checkout -b $*
gbd=git branch --delete $*
gbm=git branch --move $*
gbs=git show-branch $*

;= Git Commit
gc=git commit -v $*
gca=git commit -v --all $*
gcF=git commit -v --amend $*
gcm=git commit --message $*
gcp=git cherry-pick --ff $*
gcS=git commit --gpg-sign $*
gcSF=git commit --amend --gpg-sign $*
gco=git checkout $*
gcs=git show $*

;= Git Diff
gd=git diff $*
gdc=git diff --cached $*

;= Git Fetch
gf=git fetch --all --tags --prune $*
gfc=git clone $*
gfcr=git clone --recurse-submodules $*
gfm=git pull
gfr=git pull --rebase
gfx="C:\workspace\aliases\gfx.cmd" $*
gfu=git remote --verbose update --prune $*

;= Git Grep
gg=git grep $*
ggi=git grep --interactive $*
ggl=git grep --files-with-matches $*
ggv=git grep --invert-match $*
ggw=git grep --word-regexp $*

;= Git Index
gia=git add $*
gid=git diff --cached $*
gir=git reset $*

;= Git Log Author
gl=git log --topo-order --pretty=format:"%C(4)%aN %C(7)<%aE> %C(4)%ar %C(3)%ad %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --first-parent $*
gla=git log --topo-order --pretty=format:"%C(4)%aN %C(7)<%aE> %C(4)%ar %C(3)%ad %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --all $*
glag=git log --topo-order --pretty=format:"%C(4)%aN %C(7)<%aE> %C(4)%ar %C(3)%ad %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --all --graph $*
gld=git log --topo-order --pretty=format:"%C(4)%aN %C(7)<%aE> %C(4)%ar %C(3)%ad %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --no-merges --first-parent $*
gldp=git log --topo-order --pretty=format:"%C(4)%aN %C(7)<%aE> %C(4)%ar %C(3)%ad %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --no-merges --first-parent --patch $*
glg=git log --topo-order --pretty=format:"%C(4)%aN %C(7)<%aE> %C(4)%ar %C(3)%ad %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --graph $*

;= Git Log Committer
glc=git log --topo-order --pretty=format:"%C(4)%cN %C(7)<%cE> %C(4)%cr %C(3)%cd %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --first-parent $*
glca=git log --topo-order --pretty=format:"%C(4)%cN %C(7)<%cE> %C(4)%cr %C(3)%cd %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --all $*
glcag=git log --topo-order --pretty=format:"%C(4)%cN %C(7)<%cE> %C(4)%cr %C(3)%cd %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --all --graph $*
glcd=git log --topo-order --pretty=format:"%C(4)%cN %C(7)<%cE> %C(4)%cr %C(3)%cd %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --no-merges --first-parent $*
glcdp=git log --topo-order --pretty=format:"%C(4)%cN %C(7)<%cE> %C(4)%cr %C(3)%cd %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --no-merges --first-parent --patch $*
glcg=git log --topo-order --pretty=format:"%C(4)%cN %C(7)<%cE> %C(4)%cr %C(3)%cd %C(2)%h%C(3)%d %C(7)%<(80,trunc)%s" --graph $*

gls=git log --topo-order --stat --pretty=format:"${_git_log_medium_format}" $*

;= Git Merge
gm=git merge $*
gma=git merge --abort $*
gmt=git mergetool $*

;= Git Push
gp=git push $*
gpt=git push --tags $*

;= Git Rebase
gr=git rebase $*
gra=git rebase --abort $*
grc=git rebase --continue $*
gri=git rebase --interactive $*

;= Git Remote

;= Git Stash
gs=git stash $*
gsa=git stash apply $*
gsd=git stash show --patch --stat $*
gsx=git stash drop $*
gsl=git stash list $*
gsp=git stash pop $*
gss=git stash save --include-untracked $*

;= Git Working Copy
gwa=git add --verbose $*
gws=git status $*
gwd=git diff $*
gwr=git reset --soft $*
gwc=git clean $*

Add --first-parent to windows aliases gl and glc


Create hent.bat

Create hent.bat


cd Python\Scripts && activate && cd .. && cd .. && python runserver.py

Update zombie_server.bat

Update zombie_server.bat


@echo off
setlocal enableextensions

goto entry

:usage
  echo usage: jsc dev      [-c^|--config CONFIG_JS] [BOOTSTRAP_TARGET]
  echo     or jsc compile  [-c^|--config CONFIG_JS] MODULE_FILE ... COMPILE_TARGET
  echo     or jsc identify MODULE_FILE
  echo     or jsc inline   [-c^|--config CONFIG_JS] [-n^|--invoke-main MAIN_MODULE] [-r^|--register] COMPILE_FILE ... LINK_TARGET
  echo     or jsc link     [-c^|--config CONFIG_JS] COMPILE_FILE ... LINK_TARGET
  echo     or jsc help
  echo.
  echo arguments:
  echo   BOOTSTRAP_TARGET file to generate for running in dev mode, this defaults
  echo                    to a file called bootstrap.js in the same directory as
  echo                    the config file
  echo   MODULE_FILE      file containing an uncompiled module
  echo   COMPILE_TARGET   file to generate when compiling, will contain the set of
  echo                    modules and their dependencies
  echo   COMPILE_FILE     file produced by compilation to use as input to linking,
  echo                    COMPILE_FILE must have corresponding 'COMPILE_TARGET.meta'
  echo   LINK_TARGET      file to generate when linking, will contain bootstrap
  echo                    information: bolt, install and configuration
  echo.
  echo options:
  echo   -c^|--config CONFIG_JS          override bolt configuration file
  echo                                    default: config/bolt/prod.js
  echo   -o^|--output OUTPUT_DIR         override compilation output directory
  echo                                    default: scratch/main/js/compile
  echo   -n^|--invoke-main MAIN_MODULE   specify main module of inline scripts
  echo   -r^|--register                  register modules in global namespace
  echo.

  exit /b 0

:fail_usage
  echo.
  call :usage
  exit /b 1

:fail
  exit /b 1

:entry

set base=%~dp0

if "%~1"=="" echo error: must specify mode. && goto fail_usage

set mode=%~1
shift

if "%mode%"=="dev" goto done_mode_validation
if "%mode%"=="compile" goto done_mode_validation
if "%mode%"=="identify" goto done_mode_validation
if "%mode%"=="inline" goto done_mode_validation
if "%mode%"=="link" goto done_mode_validation
if "%mode%"=="help" goto done_mode_validation

echo invalid mode [%mode%], must be one of dev^|compile^|identify^|inline^|link^|help
goto fail_usage

:done_mode_validation

if "%mode%"=="help" call :usage && exit /b 0

:parse_flags
  set flag=%~1
  if not "%flag:~0,1%"=="-" goto done_parse_flags
  shift

  if "%flag%"=="-c" goto parse_config
  if "%flag%"=="--config" goto parse_config
  if "%flag%"=="-o" goto parse_output
  if "%flag%"=="--output" goto parse_output
  if "%flag%"=="-n" goto parse_invoke
  if "%flag%"=="--invoke-main" goto parse_invoke
  if "%flag%"=="-r" goto parse_register
  if "%flag%"=="--register" goto parse_register
  if "%flag%"=="--" goto done_parse_flags
  echo invalid flag [%flag%] && goto fail_usage

  goto parse_flags

  :parse_config
    if "%~1"=="" echo %flag% requires an argument to be specified && goto fail_usage
    set config_js=%~1
    shift
  goto parse_flags

  :parse_output
    if "%~1"=="" echo %flag% requires an argument to be specified && goto fail_usage
    set output_dir=%~1
    shift
  goto parse_flags

  :parse_invoke
    if "%~1"=="" echo %flag% requires an argument to be specified && goto fail_usage
    set invoke_main=true
    set main=%~1
    shift
  goto parse_flags

  :parse_register
    set register_modules=true
  goto parse_flags

:done_parse_flags

if "%config_js%"=="" set config_js=config/bolt/prod.js
if "%output_dir%"=="" set output_dir=scratch/main/js/compile
if "%register_modules%"=="" set register_modules=false
if "%invoke_main%"=="" set invoke_main=false

if not exist "%config_js%" echo %config_js% does not exist or is not a file && goto fail
for %%i in ("%config_js%") do if exist %%~si\NUL echo %config_js% does not exist or is not a file && goto fail

for %%i in (node.exe) do set node=%%~$PATH:i
if "%node%"=="" echo error: node.js is not on the system path && goto fail

if "%mode%"=="dev" goto jsc_dev
if "%mode%"=="compile" goto jsc_compile
if "%mode%"=="identify" goto jsc_identify
if "%mode%"=="inline" goto jsc_inline
if "%mode%"=="link" goto jsc_link
exit /b 0

:jsc_dev
  if "%~1"=="" for %%F in ("%config_js%") do (set bootstrap=%%~dpFbootstrap.js) && goto exec_jsc_dev
  if "%~2"=="" set bootstrap=%~1 && goto exec_jsc_dev
  echo invalid number of arguments for jsc %mode%
  goto fail_usage

  :exec_jsc_dev
    "%node%" "%base%jsc.js" "%mode%" "%bootstrap%" "%config_js%"
exit /b 0

:jsc_compile
  goto jsc_x

:jsc_identify
  if "%~1"=="" echo invalid number of arguments for jsc %mode% && goto fail_usage
  if not "%~2"=="" echo invalid number of arguments for jsc %mode% && goto fail_usage
  "%node%" "%base%jsc.js" "%mode%" "%~1"
exit /b 0

:jsc_inline
  if "%~1"=="" echo invalid number of arguments for jsc %mode% && goto fail_usage
  if "%~2"=="" echo invalid number of arguments for jsc %mode% && goto fail_usage

  :jsc_inline_remaining
  if "%~1"=="" goto end_jsc_inline_remaining
  set remaining=%remaining% "%~1"
  shift
  goto :jsc_inline_remaining
  :end_jsc_inline_remaining

  "%node%" "%base%jsc.js" "%mode%" "%config_js%" "%invoke_main%" "%main%" "%register_modules%" %remaining%
exit /b 0

:jsc_link
  goto jsc_x

:jsc_x
  if "%~1"=="" echo invalid number of arguments for jsc %mode% && goto fail_usage
  if "%~2"=="" echo invalid number of arguments for jsc %mode% && goto fail_usage

  :jsc_x_remaining
  if "%~1"=="" goto end_jsc_x_remaining
  set remaining=%remaining% "%~1"
  shift
  goto :jsc_x_remaining
  :end_jsc_x_remaining

  "%node%" "%base%jsc.js" "%mode%" "%config_js%" %remaining%
exit /b 0

Add batch file implementation of jsc

Add batch file implementation of jsc


:: Copyright 2012 The Go Authors. All rights reserved.
:: Use of this source code is governed by a BSD-style
:: license that can be found in the LICENSE file.

@echo off

if exist ..\bin\go.exe goto ok
echo Must run run.bat from Go src directory after installing cmd/go.
goto fail
:ok

:: Keep environment variables within this script
:: unless invoked with --no-local.
if x%1==x--no-local goto nolocal
if x%2==x--no-local goto nolocal
setlocal
:nolocal

set GOBUILDFAIL=0

:: we disallow local import for non-local packages, if %GOROOT% happens
:: to be under %GOPATH%, then some tests below will fail
set GOPATH=
:: Issue 14340: ignore GOBIN during all.bat.
set GOBIN=
set GOFLAGS=
set GO111MODULE=

rem TODO avoid rebuild if possible

if x%1==x--no-rebuild goto norebuild
echo ##### Building packages and commands.
go install -a -v std cmd
if errorlevel 1 goto fail
echo.
:norebuild

:: we must unset GOROOT_FINAL before tests, because runtime/debug requires
:: correct access to source code, so if we have GOROOT_FINAL in effect,
:: at least runtime/debug test will fail.
set GOROOT_FINAL=

:: get CGO_ENABLED
..\bin\go env > env.bat
if errorlevel 1 goto fail
call env.bat
del env.bat
echo.

..\bin\go tool dist test
if errorlevel 1 goto fail
echo.

goto end

:fail
set GOBUILDFAIL=1

:end

:: Copyright 2012 The Go Authors. All rights reserved.
:: Use of this source code is governed by a BSD-style
:: license that can be found in the LICENSE file.

@echo off

if exist ..\bin\go.exe goto ok
echo Must run run.bat from Go src directory after installing cmd/go.
goto fail
:ok

:: Keep environment variables within this script
:: unless invoked with --no-local.
if x%1==x--no-local goto nolocal
if x%2==x--no-local goto nolocal
setlocal
:nolocal

set GOBUILDFAIL=0

:: we disallow local import for non-local packages, if %GOROOT% happens
:: to be under %GOPATH%, then some tests below will fail
set GOPATH=
:: Issue 14340: ignore GOBIN during all.bat.
set GOBIN=
set GOFLAGS=
set GO111MODULE=

rem TODO avoid rebuild if possible

if x%1==x--no-rebuild goto norebuild
echo ##### Building packages and commands.
..\bin\go install -a -v std cmd
if errorlevel 1 goto fail
echo.
:norebuild

:: we must unset GOROOT_FINAL before tests, because runtime/debug requires
:: correct access to source code, so if we have GOROOT_FINAL in effect,
:: at least runtime/debug test will fail.
set GOROOT_FINAL=

:: get CGO_ENABLED
..\bin\go env > env.bat
if errorlevel 1 goto fail
call env.bat
del env.bat
echo.

..\bin\go tool dist test
if errorlevel 1 goto fail
echo.

goto end

:fail
set GOBUILDFAIL=1

:end

run.bat: use ..\bin\go instead of "go" to install std and cmd

The paths for the other "go" commands in this file were fixed in CL 223741,
but this one was missed (and run.bat is not caught by the builders).

Change-Id: Iba1efddc7d2fbe6af39c39d643508decc954bbc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/234758
Run-TryBot: Bryan C. Mills <1c8aad60184261ccede67f5c63a0d2a3bf3c9ff4@google.com>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Dmitri Shuralyov <d181b7fea0ec87c86ba5a890ab716db52498e3ba@golang.org>


@ECHO off
TITLE Downloading NadekoBot, please wait
::Setting convenient to read variables which don't delete the windows temp folder
SET root=%~dp0
CD /D %root%
SET rootdir=%cd%
SET build1=%root%NadekoInstall_Temp\NadekoBot\Discord.Net\src\Discord.Net.Core\
SET build2=%root%NadekoInstall_Temp\NadekoBot\Discord.Net\src\Discord.Net.Rest\
SET build3=%root%NadekoInstall_Temp\NadekoBot\Discord.Net\src\Discord.Net.WebSocket\
SET build4=%root%NadekoInstall_Temp\NadekoBot\Discord.Net\src\Discord.Net.Commands\
SET build5=%root%NadekoInstall_Temp\NadekoBot\src\NadekoBot\
SET installtemp=%root%NadekoInstall_Temp\
::Deleting traces of last setup for the sake of clean folders, if by some miracle it still exists
IF EXIST %installtemp% ( RMDIR %installtemp% /S /Q >nul 2>&1)
::Checks that both git and dotnet are installed
dotnet --version >nul 2>&1 || GOTO :dotnet
git --version >nul 2>&1 || GOTO :git
::Creates the install directory to work in and get the current directory because spaces ruins everything otherwise
:start
MKDIR NadekoInstall_Temp
CD /D %installtemp%
::Downloads the latest version of Nadeko
ECHO Downloading Nadeko...
ECHO.
git clone -b dev --recursive --depth 1 --progress https://github.com/Kwoth/NadekoBot.git >nul
IF %ERRORLEVEL% EQU 128 (GOTO :giterror)
TITLE Installing NadekoBot, please wait
ECHO.
ECHO Installing...
::Building Nadeko
CD /D %build1%
dotnet restore >nul 2>&1
CD /D %build2%
dotnet restore >nul 2>&1
CD /D %build3%
dotnet restore >nul 2>&1
CD /D %build4%
dotnet restore >nul 2>&1
CD /D %build5%
dotnet restore >nul 2>&1
dotnet build --configuration Release >nul 2>&1
::Attempts to backup old files if they currently exist in the same folder as the batch file
IF EXIST "%root%NadekoBot\" (GOTO :backupinstall)
:freshinstall
	::Moves the NadekoBot folder to keep things tidy
	ROBOCOPY "%root%NadekoInstall_Temp" "%rootdir%" /E /MOVE >nul 2>&1
	IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror)
	GOTO :end
:backupinstall
	TITLE Backing up old files
	::Recursively copies all files and folders from NadekoBot to NadekoBot_Old
	ROBOCOPY "%root%NadekoBot" "%root%NadekoBot_Old" /MIR >nul 2>&1
	IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror)
	ECHO.
	ECHO Old files backed up to NadekoBot_Old
	::Copies the credentials and database from the backed up data to the new folder
	COPY "%root%NadekoBot_Old\src\NadekoBot\credentials.json" "%installtemp%NadekoBot\src\NadekoBot\credentials.json" >nul 2>&1
	IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror)
	ECHO.
	ECHO credentials.json copied to new folder
	ROBOCOPY "%root%NadekoBot_Old\src\NadekoBot\bin" "%installtemp%NadekoBot\src\NadekoBot\bin" /E >nul 2>&1
	IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror)
	ECHO.
	ECHO Old bin folder copied to new folder
	ROBOCOPY "%root%NadekoBot_Old\src\NadekoBot\data" "%installtemp%NadekoBot\src\NadekoBot\data" /E >nul 2>&1
	IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror)
	ECHO.
	ECHO Old data folder copied to new folder
	::Moves the setup Nadeko folder
	RMDIR "%root%NadekoBot\" /S /Q >nul 2>&1
	ROBOCOPY "%root%NadekoInstall_Temp" "%rootdir%" /E /MOVE >nul 2>&1
	IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror)
	GOTO :end
:dotnet
	::Terminates the batch script if it can't run dotnet --version
	TITLE Error!
	ECHO dotnet not found, make sure it's been installed as per the guides instructions!
	ECHO Press any key to exit.
	PAUSE >nul 2>&1
	CD /D "%root%"
	GOTO :EOF
:git
	::Terminates the batch script if it can't run git --version
	TITLE Error!
	ECHO git not found, make sure it's been installed as per the guides instructions!
	ECHO Press any key to exit.
	PAUSE >nul 2>&1
	CD /D "%root%"
	GOTO :EOF
:giterror
	ECHO.
	ECHO Git clone failed, trying again
	RMDIR %installtemp% /S /Q >nul 2>&1
	GOTO :start
:copyerror
	::If at any point a copy error is encountered
	TITLE Error!
	ECHO.
	ECHO An error in copying data has been encountered, returning an exit code of %ERRORLEVEL%
	ECHO.
	ECHO Make sure to close any files, such as `NadekoBot.db` before continuing or try running the installer as an Administrator
	PAUSE >nul 2>&1
	CD /D "%root%"
	GOTO :EOF
:end
	::Normal execution of end of script
	TITLE Installation complete!
	CD /D "%root%"
	RMDIR /S /Q "%installtemp%" >nul 2>&1
	ECHO.
	ECHO Installation complete, press any key to close this window!
	PAUSE >nul 2>&1
	del Latest.bat

@ECHO off
TITLE Downloading NadekoBot, please wait
::Setting convenient to read variables which don't delete the windows temp folder
SET root=%~dp0
CD /D %root%
SET rootdir=%cd%
SET build1=%root%NadekoInstall_Temp\NadekoBot\Discord.Net\src\Discord.Net.Core\
SET build2=%root%NadekoInstall_Temp\NadekoBot\Discord.Net\src\Discord.Net.Rest\
SET build3=%root%NadekoInstall_Temp\NadekoBot\Discord.Net\src\Discord.Net.WebSocket\
SET build4=%root%NadekoInstall_Temp\NadekoBot\Discord.Net\src\Discord.Net.Commands\
SET build5=%root%NadekoInstall_Temp\NadekoBot\src\NadekoBot\
SET installtemp=%root%NadekoInstall_Temp\
::Deleting traces of last setup for the sake of clean folders, if by some miracle it still exists
IF EXIST %installtemp% ( RMDIR %installtemp% /S /Q >nul 2>&1)
::Checks that both git and dotnet are installed
dotnet --version >nul 2>&1 || GOTO :dotnet
git --version >nul 2>&1 || GOTO :git
::Creates the install directory to work in and get the current directory because spaces ruins everything otherwise
:start
MKDIR NadekoInstall_Temp
CD /D %installtemp%
::Downloads the latest version of Nadeko
ECHO Downloading Nadeko...
ECHO.
git clone -b dev --recursive --depth 1 --progress https://github.com/Kwoth/NadekoBot.git >nul
IF %ERRORLEVEL% EQU 128 (GOTO :giterror)
TITLE Installing NadekoBot, please wait
ECHO.
ECHO Installing...
::Building Nadeko
CD /D %build1%
dotnet restore >nul 2>&1
CD /D %build2%
dotnet restore >nul 2>&1
CD /D %build3%
dotnet restore >nul 2>&1
CD /D %build4%
dotnet restore >nul 2>&1
CD /D %build5%
dotnet restore >nul 2>&1
dotnet build --configuration Release >nul 2>&1
::Attempts to backup old files if they currently exist in the same folder as the batch file
IF EXIST "%root%NadekoBot\" (GOTO :backupinstall)
:freshinstall
	::Moves the NadekoBot folder to keep things tidy
	ROBOCOPY "%root%NadekoInstall_Temp" "%rootdir%" /E /MOVE >nul 2>&1
	IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror)
	GOTO :end
:backupinstall
	TITLE Backing up old files
	::Recursively copies all files and folders from NadekoBot to NadekoBot_Old
	ROBOCOPY "%root%NadekoBot" "%root%NadekoBot_Old" /MIR >nul 2>&1
	IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror)
	ECHO.
	ECHO Old files backed up to NadekoBot_Old
	::Copies the credentials and database from the backed up data to the new folder
	COPY "%root%NadekoBot_Old\src\NadekoBot\credentials.json" "%installtemp%NadekoBot\src\NadekoBot\credentials.json" >nul 2>&1
	IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror)
	ECHO.
	ECHO credentials.json copied to new folder
	ROBOCOPY "%root%NadekoBot_Old\src\NadekoBot\bin" "%installtemp%NadekoBot\src\NadekoBot\bin" /E >nul 2>&1
	IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror)
	ECHO.
	ECHO Old bin folder copied to new folder
	ROBOCOPY "%root%NadekoBot_Old\src\NadekoBot\data" "%installtemp%NadekoBot\src\NadekoBot\data" /E >nul 2>&1
	IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror)
	ECHO.
	ECHO Old data folder copied to new folder
	::Moves the setup Nadeko folder
	RMDIR "%root%NadekoBot\" /S /Q >nul 2>&1
	ROBOCOPY "%root%NadekoInstall_Temp" "%rootdir%" /E /MOVE >nul 2>&1
	IF %ERRORLEVEL% GEQ 8 (GOTO :copyerror)
	GOTO :end
:dotnet
	::Terminates the batch script if it can't run dotnet --version
	TITLE Error!
	ECHO dotnet not found, make sure it's been installed as per the guides instructions!
	ECHO Press any key to exit.
	PAUSE >nul 2>&1
	CD /D "%root%"
	GOTO :EOF
:git
	::Terminates the batch script if it can't run git --version
	TITLE Error!
	ECHO git not found, make sure it's been installed as per the guides instructions!
	ECHO Press any key to exit.
	PAUSE >nul 2>&1
	CD /D "%root%"
	GOTO :EOF
:giterror
	ECHO.
	ECHO Git clone failed, trying again
	RMDIR %installtemp% /S /Q >nul 2>&1
	GOTO :start
:copyerror
	::If at any point a copy error is encountered
	TITLE Error!
	ECHO.
	ECHO An error in copying data has been encountered, returning an exit code of %ERRORLEVEL%
	ECHO.
	ECHO Make sure to close any files, such as `NadekoBot.db` before continuing or try running the installer as an Administrator
	PAUSE >nul 2>&1
	CD /D "%root%"
	GOTO :EOF
:end
	::Normal execution of end of script
	TITLE Installation complete!
	CD /D "%root%"
	RMDIR /S /Q "%installtemp%" >nul 2>&1
	ECHO.
	ECHO Installation complete, press any key to close this window!
	timeout /t 5
	del Latest.bat

Update Latest.bat

Update Latest.bat