@echo off
setlocal enableDelayedExpansion

REM Setup initial vars
set "script_name=%~n0.command"
set "thisDir=%~dp0"
set /a tried=0
set "toask=yes"

goto checkscript

:checkscript
REM Check for our script first
if not exist "!thisDir!\!script_name!" (
    echo Could not find !script_name!.
    echo Please make sure to run this script from the same directory
    echo as !script_name!.
    echo.
    echo Press [enter] to quit.
    pause > nul
    exit /b
)
goto checkpy

:checkpy
python -V > NUL 2>&1
if not "!errorlevel!" == "0" (
    if %tried% lss 1 (
        if /i "!toask!"=="yes" (
            REM Better ask permission first
            goto askinstall
        ) else (
            goto installpy
        )
    ) else (
        cls
        echo   ###     ###
        echo  # Warning #
        echo ###     ###
        REM Couldn't install for whatever reason - give the error message
        echo Python is not installed or not found in your PATH var.
        echo Please install it from https://www.python.org/downloads/windows/
        echo.
        echo Make sure you check the box labeled:
        echo.
        echo "Add Python X.X to PATH"
        echo.
        echo Where X.X is the py version you're installing.
        echo.
        echo Press [enter] to quit.
        pause > nul
        exit /b
    )
)
goto runscript

:askinstall
cls
echo   ###              ###
echo  # Python Not Found #
echo ###              ###
echo.
echo Python was not found on the system or in the PATH var.
echo.
set /p "menu=Would you like to install it now? [y/n]: "
if /i "!menu!"=="y" (
    REM We got the OK - install it
    goto installpy
) else if "!menu!"=="n" (
    REM No OK here...
    set /a tried=%tried%+1
    goto checkpy
)
REM Incorrect answer - go back
goto askinstall

:installpy
REM This will attempt to download and install python
REM First we get the html for the python downloads page for Windows
set /a tried=%tried%+1
cls
echo   ###               ###
echo  # Installing Python #
echo ###               ###
echo.
echo Gathering info from https://www.python.org/downloads/windows/...
powershell -command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (new-object System.Net.WebClient).DownloadFile('https://www.python.org/downloads/windows/','%TEMP%\pyurl.txt')"
if not exist "%TEMP%\pyurl.txt" (
    goto checkpy
)

echo Parsing for latest...
pushd "%TEMP%"
:: Version detection code slimmed by LussacZheng (https://github.com/corpnewt/gibMacOS/issues/20)
for /f "tokens=9 delims=< " %%x in ('findstr /i /c:"Latest Python 3 Release" pyurl.txt') do ( set "release=%%x" )
popd

echo Found Python !release! -  Downloading...
REM Let's delete our txt file now - we no longer need it
del "%TEMP%\pyurl.txt"

REM At this point - we should have the version number.
REM We can build the url like so: "https://www.python.org/ftp/python/[version]/python-[version]-amd64.exe"
set "url=https://www.python.org/ftp/python/!release!/python-!release!-amd64.exe"
REM Now we download it with our slick powershell command
powershell -command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (new-object System.Net.WebClient).DownloadFile('!url!','%TEMP%\pyinstall.exe')"
REM If it doesn't exist - we bail
if not exist "%TEMP%\pyinstall.exe" (
    goto checkpy
)
REM It should exist at this point - let's run it to install silently
echo Installing...
echo pyinstall.exe /quiet PrependPath=1 Include_test=0 Shortcuts=0 Include_launcher=0
pushd "%TEMP%"
pyinstall.exe /quiet PrependPath=1 Include_test=0 Shortcuts=0 Include_launcher=0
popd
echo Installer finsihed with %ERRORLEVEL% status.
REM Now we should be able to delete the installer and check for py again
del "%TEMP%\pyinstall.exe"
REM If it worked, then we should have python in our PATH
REM this does not get updated right away though - let's try
REM manually updating the local PATH var
set "spath="
set "upath="
for /f "tokens=2* delims= " %%i in ('reg.exe query "HKCU\Environment" /v "Path" 2^> nul') do (
    if NOT "%%j"=="" (
		set "upath=%%j"
	)
)
for /f "tokens=2* delims= " %%i in ('reg.exe query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v "Path" 2^> nul') do (
    if NOT "%%j"=="" (
		set "spath=%%j"
	)
)
if not "!spath!" == "" (
    REM We got something in the system path
    set "PATH=!spath!"
    if not "!upath!" == "" (
        REM We also have something in the user path
        set "PATH=!PATH!;!upath!"
    )
) else if not "!upath!" == "" (
    set "PATH=!upath!"
)
goto checkpy
exit /b

:runscript
REM Python found
cls
set "args=%*"
set "args=!args:"=!"
if "!args!"=="" (
    python "!thisDir!!script_name!"
) else (
    python "!thisDir!!script_name!" %*
)
goto :EOF

@echo off
setlocal enableDelayedExpansion

REM Setup initial vars
set "script_name=%~n0.command"
set "thisDir=%~dp0"
set /a tried=0
set "toask=yes"
set "py2v="
set "py2path="
set "py3v="
set "py3path="
set "pypath="

REM use_py3:
REM   TRUE  = Use if found, use py2 otherwise
REM   FALSE = Use py2
REM   FORCE = Use py3
set "use_py3=TRUE"

goto checkscript

:checkscript
REM Check for our script first
if not exist "!thisDir!\!script_name!" (
    echo Could not find !script_name!.
    echo Please make sure to run this script from the same directory
    echo as !script_name!.
    echo.
    echo Press [enter] to quit.
    pause > nul
    exit /b
)
goto checkpy

:checkpy
for /f "tokens=1" %%x in ('where python') do ( call :checkpyversion "%%x" "py2v" "py2path" "py3v" "py3path" )
set "targetpy=3"
if /i "!use_py3!" == "FALSE" (
    set "targetpy=2"
    set "pypath=!py2path!"
) else if /i "!use_py3!" == "FORCE" (
    set "pypath=!py3path!"
) else if /i "!use_py3!" == "TRUE" (
    set "pypath=!py3path!"
    if "!pypath!" == "" set "pypath=!py2path!"
)
if not "!pypath!" == "" (
    goto runscript
)

if "!pypath!" == "" (
    if %tried% lss 1 (
        if /i "!toask!"=="yes" (
            REM Better ask permission first
            goto askinstall
        ) else (
            goto installpy
        )
    ) else (
        cls
        echo   ###     ###
        echo  # Warning #
        echo ###     ###
        echo.
        REM Couldn't install for whatever reason - give the error message
        echo Python is not installed or not found in your PATH var.
        echo Please install it from https://www.python.org/downloads/windows/
        echo.
        echo Make sure you check the box labeled:
        echo.
        echo "Add Python X.X to PATH"
        echo.
        echo Where X.X is the py version you're installing.
        echo.
        echo Press [enter] to quit.
        pause > nul
        exit /b
    )
)
goto runscript

:checkpyversion <path> <py2v> <py2path> <py3v> <py3path>
set "version="&for /f "tokens=2* USEBACKQ delims= " %%a in (`"%~1" -V 2^>^&1`) do (
    REM Ensure we have a version number
    call :isnumber "%%a"
    if not "!errorlevel!" == "0" goto :EOF
    set "version=%%a"
)
if not defined version goto :EOF
if "!version:~0,1!" == "2" (
    REM Python 2
    call :comparepyversion "!version!" "!%~2!"
    if "!errorlevel!" == "1" (
        set "%~2=!version!"
        set "%~3=%~1"
    )
) else (
    REM Python 3
    call :comparepyversion "!version!" "!%~4!"
    if "!errorlevel!" == "1" (
        set "%~4=!version!"
        set "%~5=%~1"
    )
)
goto :EOF

:isnumber <check>
set "var="&for /f "delims=0123456789." %%i in ("%~1") do set var=%%i
if defined var (exit /b 1)
exit /b 0

:comparepyversion <version1> <version2> <return>
REM Exits with status 0 if equal, 1 if v1 gtr v2, 2 if v1 lss v2
for /f "tokens=1,2,3 delims=." %%a in ("%~1") do (
    set a1=%%a
    set a2=%%b
    set a3=%%c
)
for /f "tokens=1,2,3 delims=." %%a in ("%~2") do (
    set b1=%%a
    set b2=%%b
    set b3=%%c
)
if not defined a1 set a1=0
if not defined a2 set a2=0
if not defined a3 set a3=0
if not defined b1 set b1=0
if not defined b2 set b2=0
if not defined b3 set b3=0
if %a1% gtr %b1% exit /b 1
if %a1% lss %b1% exit /b 2
if %a2% gtr %b2% exit /b 1
if %a2% lss %b2% exit /b 2
if %a3% gtr %b3% exit /b 1
if %a3% lss %b3% exit /b 2
exit /b 0

:askinstall
cls
echo   ###              ###
echo  # Python Not Found #
echo ###              ###
echo.
echo Python !targetpy! was not found on the system or in the PATH var.
echo.
set /p "menu=Would you like to install it now? [y/n]: "
if /i "!menu!"=="y" (
    REM We got the OK - install it
    goto installpy
) else if "!menu!"=="n" (
    REM No OK here...
    set /a tried=%tried%+1
    goto checkpy
)
REM Incorrect answer - go back
goto askinstall

:installpy
REM This will attempt to download and install python
REM First we get the html for the python downloads page for Windows
set /a tried=%tried%+1
cls
echo   ###               ###
echo  # Installing Python #
echo ###               ###
echo.
echo Gathering info from https://www.python.org/downloads/windows/...
powershell -command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (new-object System.Net.WebClient).DownloadFile('https://www.python.org/downloads/windows/','%TEMP%\pyurl.txt')"
if not exist "%TEMP%\pyurl.txt" (
    goto checkpy
)

echo Parsing for latest...
pushd "%TEMP%"
:: Version detection code slimmed by LussacZheng (https://github.com/corpnewt/gibMacOS/issues/20)
for /f "tokens=9 delims=< " %%x in ('findstr /i /c:"Latest Python !targetpy! Release" pyurl.txt') do ( set "release=%%x" )
popd

echo Found Python !release! -  Downloading...
REM Let's delete our txt file now - we no longer need it
del "%TEMP%\pyurl.txt"

REM At this point - we should have the version number.
REM We can build the url like so: "https://www.python.org/ftp/python/[version]/python-[version]-amd64.exe"
set "url=https://www.python.org/ftp/python/!release!/python-!release!-amd64.exe"
set "pytype=exe"
if "!targetpy!" == "2" (
    set "url=https://www.python.org/ftp/python/!release!/python-!release!.amd64.msi"
    set "pytype=msi"
)
REM Now we download it with our slick powershell command
powershell -command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (new-object System.Net.WebClient).DownloadFile('!url!','%TEMP%\pyinstall.!pytype!')"
REM If it doesn't exist - we bail
if not exist "%TEMP%\pyinstall.!pytype!" (
    goto checkpy
)
REM It should exist at this point - let's run it to install silently
echo Installing...
pushd "%TEMP%"
if /i "!pytype!" == "exe" (
    echo pyinstall.exe /quiet PrependPath=1 Include_test=0 Shortcuts=0 Include_launcher=0
    pyinstall.exe /quiet PrependPath=1 Include_test=0 Shortcuts=0 Include_launcher=0
) else (
    set "foldername=!release:.=!"
    echo msiexec /i pyinstall.msi /qb ADDLOCAL=ALL TARGETDIR="%LocalAppData%\Programs\Python\Python!foldername:~0,2!"
    msiexec /i pyinstall.msi /qb ADDLOCAL=ALL TARGETDIR="%LocalAppData%\Programs\Python\Python!foldername:~0,2!"
)
popd
echo Installer finished with %ERRORLEVEL% status.
REM Now we should be able to delete the installer and check for py again
del "%TEMP%\pyinstall.!pytype!"
REM If it worked, then we should have python in our PATH
REM this does not get updated right away though - let's try
REM manually updating the local PATH var
set "spath="
set "upath="
for /f "tokens=2* delims= " %%i in ('reg.exe query "HKCU\Environment" /v "Path" 2^> nul') do ( if not "%%j" == "" set "upath=%%j" )
for /f "tokens=2* delims= " %%i in ('reg.exe query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v "Path" 2^> nul') do ( if not "%%j" == "" set "spath=%%j" )
if not "!spath!" == "" (
    REM We got something in the system path
    set "PATH=!spath!"
    if not "!upath!" == "" (
        REM We also have something in the user path
        set "PATH=!PATH!;!upath!"
    )
) else if not "!upath!" == "" (
    set "PATH=!upath!"
)
goto checkpy
exit /b

:runscript
REM Python found
cls
set "args=%*"
set "args=!args:"=!"
if "!args!"=="" (
    "!pypath!" "!thisDir!!script_name!"
) else (
    "!pypath!" "!thisDir!!script_name!" %*
)
goto :EOF

Expand python detection

Expand python detection


@echo off
REM  Backup script for Opera 15 and up

REM  Get options
SET OPTION=%1
SET GITEXIST=

REM  INIT
REM  ====
REM  Check if sqlite3.exe exist in the path folders ( Nice solution by Joey! http://bit.ly/16CqIVQ )
for %%X in (sqlite3.exe) do (set SQLFOUND=%%~$PATH:X)
IF NOT DEFINED SQLFOUND (
    ECHO.WARNING: sqlite3 is not in path. Will not be able to dump databases.
) ELSE (
	ECHO.Using %SQLFOUND%
)
for %%X in (git.exe) do (set GITFOUND=%%~$PATH:X)
IF NOT DEFINED GITFOUND (
	ECHO.WARNING: git is not in path. Will not be able to commit changes. All files will be overwritten.
	SET /p CONTINUE="Overwrite files? [Y/N]: " %=%
	IF NOT CONTINUE==Y (
		ECHO.EXIT: Batch aborted by user. User does not wish to overwrite files.
		GOTO CLEANEXIT
	)
) ELSE (
	ECHO.Using %GITFOUND%
)

REM  COPY FILES TO BACKUP FOLDER
FOR %%f IN (Bookmarks;favorites.db;Preferences;session.db;stash.db) DO (
	IF EXIST %%f (
		IF NOT EXIST backup (
			mkdir backup
		)
		copy /Y %%f ./backup/%%f
	)
)

REM  IF SQLITE EXIST, DUMP FILES

REM  IF GIT EXIST, COMMIT CHANGES

IF NOT ERRORLEVEL 1 GOTO CLEANEXIT

:DIRTYEXIT
echo.
echo. This exit should not happen, an uncatched exit exist in the script
exit /b

:FATALEXIT
echo.
echo.An error occured that prevents the script from finishing. Nothing was changed.
echo.
exit /b

:DESTRUCTIVEEXIT
echo.
echo.Oh no! An error occured while performing changes. The job was only partly finished.
echo.
exit /b

:CLEANEXIT
set errorlevel=0
exit /b

Make backup of important configuration and data files in an Opera v15+ installation.


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

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

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

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

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

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

@echo.
@echo ^=^=^> Commit changes to master:
@call git add .
@call git commit -m ":rocket: deploy website"
@call git push origin master

@echo.
@echo ^=^=^> Go back to develop:
@call git checkout develop

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

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

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

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

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

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

@echo.
@echo ^=^=^> Commit changes to master:
@call git add .
@call git commit -m ":rocket: deploy website"
@call git push origin master

@echo.
@echo ^=^=^> Go back to develop:
@call git checkout develop

update deploy batch

update deploy batch


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

:: ----------------------
:: KUDU Deployment Script
:: Version: 1.0.8
:: ----------------------

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

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

:: Setup
:: -----

setlocal enabledelayedexpansion

SET ARTIFACTS=%~dp0%..\artifacts

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

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

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

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

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

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

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

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

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

echo Handling .NET Web Application deployment.

:: 1. Restore NuGet packages
IF /I "AzureDemo.sln" NEQ "" (
  call :ExecuteCmd nuget restore "%DEPLOYMENT_SOURCE%\AzureDemo.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%\AzureDemo\AzureDemo.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="%DEPLOYMENT_TEMP%";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
) ELSE (
  call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\AzureDemo\AzureDemo.csproj" /nologo /verbosity:m /t:Build /p:AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
)

IF !ERRORLEVEL! NEQ 0 goto error

:: ADDED THIS BELLOW --------------------------
:: 3. Building test projects
rem echo Building test projects
"%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\AzureDemo.Tests.sln" /p:Configuration=Release;VisualStudioVersion=14.0 /verbosity:m /p:Platform="Any CPU"

IF !ERRORLEVEL! NEQ 0 (
  echo Build failed with ErrorLevel !0!
  goto error
)

:: 4. Running tests
echo Running tests
vstest.console.exe "%DEPLOYMENT_SOURCE%\AzureDemo.Tests\bin\Release\AzureDemo.Tests.dll"
IF !ERRORLEVEL! NEQ 0 goto error
:: ADDED THIS ABOVE --------------------------

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

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

Create deploy.cmd

Create deploy.cmd


@ECHO off

CHCP 65001 > NUL
CD /d "%~dp0"

SETLOCAL ENABLEEXTENSIONS
SET KEY_NAME="HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
SET VALUE_NAME=HideFileExt

FOR /F "usebackq tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
    SET ValueName=%%A
    SET ValueType=%%B
    SET ValueValue=%%C
)

IF x%ValueValue:0x0=%==x%ValueValue% (
    ECHO Unhiding file extensions...
    START CMD /c REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v HideFileExt /t REG_DWORD /d 0 /f
)
ENDLOCAL

IF EXIST %SYSTEMROOT%\py.exe (
    CMD /k py.exe -3.5 run.py
    EXIT
)

python --version > NUL 2>&1
IF %ERRORLEVEL% NEQ 0 GOTO nopython

CMD /k python run.py
GOTO end

:nopython
ECHO ERROR: Python has either not been installed or not added to your PATH.

:end
PAUSE

@ECHO off

CHCP 65001 > NUL
CD /d "%~dp0"

SETLOCAL ENABLEEXTENSIONS
SET KEY_NAME="HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
SET VALUE_NAME=HideFileExt

FOR /F "usebackq tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
    SET ValueName=%%A
    SET ValueType=%%B
    SET ValueValue=%%C
)

IF x%ValueValue:0x0=%==x%ValueValue% (
    ECHO Unhiding file extensions...
    START CMD /c REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v HideFileExt /t REG_DWORD /d 0 /f
)
ENDLOCAL

IF EXIST %SYSTEMROOT%\py.exe (
    CMD /k %SYSTEMROOT%\py.exe -3.5 run.py
    EXIT
)

python --version > NUL 2>&1
IF %ERRORLEVEL% NEQ 0 GOTO nopython

CMD /k python run.py
GOTO end

:nopython
ECHO ERROR: Python has either not been installed or not added to your PATH.

:end
PAUSE

Use sysroot var in py.exe invoke

Use sysroot var in py.exe invoke

Stupid path issues


@echo off

rem scifio.bat: the batch file that actually launches a command line tool

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

rem Include the master configuration file.
call "%SCIFIO_DIR%\config.bat"

rem Check that a command to run was specified.
if "%SCIFIO_PROG%" == "" (
  echo The command to launch must be set in the SCIFIO_PROG environment variable.
  goto end
)

rem Set the max heap size.
if "%SCIFIO_MAX_MEM%" == "" (
  rem Set a reasonable default max heap size.
  set SCIFIO_MAX_MEM=512m
)
set SCIFIO_FLAGS=-Xmx%SCIFIO_MAX_MEM%

rem Skip the update check if the NO_UPDATE_CHECK flag is set.
if not "%NO_UPDATE_CHECK%" == "" (
  set SCIFIO_FLAGS=%SCIFIO_FLAGS% -Dbioformats_can_do_upgrade_check=false
)

rem Use any available proxy settings.
set SCIFIO_FLAGS=%SCIFIO_FLAGS% -Dhttp.proxyHost=%PROXY_HOST% -Dhttp.proxyPort=%PROXY_PORT%

rem Run the command!
if not "%SCIFIO_DEVEL%" == "" (
  rem Developer environment variable set; launch with existing classpath.
  java %SCIFIO_FLAGS% %SCIFIO_PROG% %*
) else (
  rem Developer environment variable unset; add JAR libraries to classpath.
  if exist "%SCIFIO_JAR_DIR%\bio-formats.jar" (
    set SCIFIO_CP=%SCIFIO_CP%;"%SCIFIO_JAR_DIR%\bio-formats.jar"
  ) else if exist "%SCIFIO_JAR_DIR%\loci_tools.jar" (
    set SCIFIO_CP=%SCIFIO_CP%;"%SCIFIO_JAR_DIR%\loci_tools.jar"
  ) else (
    rem Libraries not found; issue an error.
    echo Required JAR libraries not found. Please download:
    echo   loci_tools.jar
    echo from:
    echo   http://www.loci.wisc.edu/bio-formats/downloads
    echo and place in the same directory as the command line tools.
    goto end
  )
  java %SCIFIO_FLAGS% -cp "%SCIFIO_DIR%";%SCIFIO_CP% %SCIFIO_PROG% %*
)

:end
rem Unset temporary SCIFIO environment variables.
set SCIFIO_CP=
set SCIFIO_DIR=
set SCIFIO_FLAGS=
set SCIFIO_PROG=

@echo off

rem scifio.bat: the batch file that actually launches a command line tool

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

rem Include the master configuration file.
call "%SCIFIO_DIR%\config.bat"

rem Check that a command to run was specified.
if "%SCIFIO_PROG%" == "" (
  echo The command to launch must be set in the SCIFIO_PROG environment variable.
  goto end
)

rem Set the max heap size.
if "%SCIFIO_MAX_MEM%" == "" (
  rem Set a reasonable default max heap size.
  set SCIFIO_MAX_MEM=512m
)
set SCIFIO_FLAGS=-Xmx%SCIFIO_MAX_MEM%

rem Skip the update check if the NO_UPDATE_CHECK flag is set.
if not "%NO_UPDATE_CHECK%" == "" (
  set SCIFIO_FLAGS=%SCIFIO_FLAGS% -Dbioformats_can_do_upgrade_check=false
)

rem Use any available proxy settings.
set SCIFIO_FLAGS=%SCIFIO_FLAGS% -Dhttp.proxyHost=%PROXY_HOST% -Dhttp.proxyPort=%PROXY_PORT%

rem Run the command!
if not "%SCIFIO_DEVEL%" == "" (
  rem Developer environment variable set; launch with existing classpath.
  java %SCIFIO_FLAGS% %SCIFIO_PROG% %*
  goto end
)

rem Developer environment variable unset; add JAR libraries to classpath.
if exist "%SCIFIO_JAR_DIR%\bio-formats.jar" (
  set SCIFIO_CP=%SCIFIO_CP%;"%SCIFIO_JAR_DIR%\bio-formats.jar"
) else if exist "%SCIFIO_JAR_DIR%\loci_tools.jar" (
  set SCIFIO_CP=%SCIFIO_CP%;"%SCIFIO_JAR_DIR%\loci_tools.jar"
) else (
  rem Libraries not found; issue an error.
  echo Required JAR libraries not found. Please download:
  echo   loci_tools.jar
  echo from:
  echo   http://www.loci.wisc.edu/bio-formats/downloads
  echo and place in the same directory as the command line tools.
  goto end
)

java %SCIFIO_FLAGS% -cp "%SCIFIO_DIR%";%SCIFIO_CP% %SCIFIO_PROG% %*

:end
rem Unset temporary SCIFIO environment variables.
set SCIFIO_CP=
set SCIFIO_DIR=
set SCIFIO_FLAGS=
set SCIFIO_PROG=

Fix bug in Windows batch launch script

Fix bug in Windows batch launch script

For details, see:
http://stackoverflow.com/questions/1687233/dos-batch-set-problem

The workaround is to avoid using altered variables inside a ( ) block.


if "%COMPILER%"=="" SET COMPILER=MSVC2015
if "%PREFIX%"=="" SET PREFIX=d:\libs2015d
if "%BOOST_ROOT%"=="" SET BOOST_ROOT=d:\boost
if "%VARIANT%"=="" SET Variant=Debug

set "ER=if ERRORLEVEL 1 exit /b 1"
if "%COMPILER%"=="MINGW" (
  SET "PATH=%PATH%;c:\mingw64\bin"
  SET "MSYSDIR=c:\msys64\usr\bin"
  SET CMAKE_TARGET="MinGW Makefiles"
  SET "CFLAGS=-I%PREFIX:\=/%/include"
  SET "CPPFLAGS=-I%PREFIX:\=/%/include"
  SET "LDFLAGS=-L%PREFIX:\=/%/lib"
  SET "CONFARGS=--prefix=%PREFIX:\=/% --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32"
  set "CMAKE=cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=%VARIANT% -DCMAKE_INSTALL_PREFIX=%PREFIX%"
  SET "MAKEC=mingw32-make"
  SET "SEDC=sed"
  SET GENERATOR="MinGW Makefiles"
  SET PREFIX1=%PREFIX:\=/%
  SET "MSBUILDINSTALL=mingw32-make install"
) else (
  if "%COMPILER%"=="MSVC2008-32"  (
      set MSC_VER=9
     set "GENERATOR= -G"Visual Studio 12 2008""
      call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86
  )
  if "%COMPILER%"=="MSVC2010-32"  (
      set MSC_VER=10
     set "GENERATOR= -G"Visual Studio 12 2010""
      call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" x86
  )
  if "%COMPILER%"=="MSVC2012"  (
     set MSC_VER=11
     set "GENERATOR= -G"Visual Studio 12 2012 Win64""
     call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
  )
  if "%COMPILER%"=="MSVC2013"  (
     set MSC_VER=12
     set "GENERATOR= -G"Visual Studio 12 2013 Win64""
     call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
  )
  if "%COMPILER%"=="MSVC2013-CTP"  (
     set MSC_VER=12
     set "GENERATOR= -G"Visual Studio 12 2013 Win64" -T CTP_Nov2013"
     call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
  )
  if "%COMPILER%"=="MSVC2015"  (
     set MSC_VER=14
     set "GENERATOR= -G"Visual Studio 14 2015 Win64""
     call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" amd64
  )
  set "CMAKE=cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=%VARIANT% -DCMAKE_INSTALL_PREFIX=%PREFIX%"
  SET "MAKEC=nmake
  SET PREFIX1=%PREFIX:\=/%
  SET "MSBUILDINSTALL=msbuild /p:Configuration=%Variant% /p:BuildInParallel=true /clp:Verbosity=normal /nologo  /flp1:logfile=build_errors.txt;errorsonly /flp2:logfile=build_warnings.txt;warningsonly INSTALL.vcxproj"
  SET "MSBUILD=msbuild /p:Configuration=%Variant% /p:BuildInParallel=true /clp:Verbosity=normal /nologo  /flp1:logfile=build_errors.txt;errorsonly /flp2:logfile=build_warnings.txt;warningsonly"
  SET "SEDC=C:\Program Files\Git\usr\bin\sed"
)

if NOT EXIST %PREFIX% mkdir %PREFIX%
if NOT EXIST %PREFIX%\include mkdir %PREFIX%\include
if NOT EXIST %PREFIX%\lib mkdir %PREFIX%\lib
if NOT EXIST %PREFIX%\bin mkdir %PREFIX%\bin

echo ============= %COMPILER% -- %VARIANT% --- %PREFIX% --- %CMAKE_TARGET% ==============

if "%COMPILER%"=="" SET COMPILER=MSVC2015
if "%PREFIX%"=="" SET PREFIX=d:\libs2015r
if "%BOOST_ROOT%"=="" SET BOOST_ROOT=d:\boost
if "%VARIANT%"=="" SET Variant=Release

set "ER=if ERRORLEVEL 1 exit /b 1"
if "%COMPILER%"=="MINGW" (
  SET "PATH=%PATH%;c:\mingw64\bin"
  SET "MSYSDIR=c:\msys64\usr\bin"
  SET CMAKE_TARGET="MinGW Makefiles"
  SET "CFLAGS=-I%PREFIX:\=/%/include"
  SET "CPPFLAGS=-I%PREFIX:\=/%/include"
  SET "LDFLAGS=-L%PREFIX:\=/%/lib"
  SET "CONFARGS=--prefix=%PREFIX:\=/% --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32"
  set "CMAKE=cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=%VARIANT% -DCMAKE_INSTALL_PREFIX=%PREFIX%"
  SET "MAKEC=mingw32-make"
  SET "SEDC=sed"
  SET GENERATOR="MinGW Makefiles"
  SET PREFIX1=%PREFIX:\=/%
  SET "MSBUILDINSTALL=mingw32-make install"
) else (
  if "%COMPILER%"=="MSVC2008-32"  (
      set MSC_VER=9
     set "GENERATOR= -G"Visual Studio 12 2008""
      call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86
  )
  if "%COMPILER%"=="MSVC2010-32"  (
      set MSC_VER=10
     set "GENERATOR= -G"Visual Studio 12 2010""
      call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" x86
  )
  if "%COMPILER%"=="MSVC2012"  (
     set MSC_VER=11
     set "GENERATOR= -G"Visual Studio 12 2012 Win64""
     call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
  )
  if "%COMPILER%"=="MSVC2013"  (
     set MSC_VER=12
     set "GENERATOR= -G"Visual Studio 12 2013 Win64""
     call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
  )
  if "%COMPILER%"=="MSVC2013-CTP"  (
     set MSC_VER=12
     set "GENERATOR= -G"Visual Studio 12 2013 Win64" -T CTP_Nov2013"
     call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
  )
  if "%COMPILER%"=="MSVC2015"  (
     set MSC_VER=14
     set "GENERATOR= -G"Visual Studio 14 2015 Win64""
     call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" amd64
  )
  set "CMAKE=cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=%VARIANT% -DCMAKE_INSTALL_PREFIX=%PREFIX%"
  SET "MAKEC=nmake
  SET PREFIX1=%PREFIX:\=/%
  SET "MSBUILDINSTALL=msbuild /p:Configuration=%Variant% /p:BuildInParallel=true /clp:Verbosity=normal /nologo  /flp1:logfile=build_errors.txt;errorsonly /flp2:logfile=build_warnings.txt;warningsonly INSTALL.vcxproj"
  SET "MSBUILD=msbuild /p:Configuration=%Variant% /p:BuildInParallel=true /clp:Verbosity=normal /nologo  /flp1:logfile=build_errors.txt;errorsonly /flp2:logfile=build_warnings.txt;warningsonly"
  SET "SEDC=C:\Program Files\Git\usr\bin\sed"
)

if NOT EXIST %PREFIX% mkdir %PREFIX%
if NOT EXIST %PREFIX%\include mkdir %PREFIX%\include
if NOT EXIST %PREFIX%\lib mkdir %PREFIX%\lib
if NOT EXIST %PREFIX%\bin mkdir %PREFIX%\bin

echo ============= %COMPILER% -- %VARIANT% --- %PREFIX% --- %CMAKE_TARGET% ==============

Use release by default

Use release by default


rem Set up the cmake build environment under Windows, to a clean state

set TI_INSTALL_ROOT=c:/ti
set CCS_INSTALL_ROOT=%TI_INSTALL_ROOT%/ccs730
set ARM_GCC_ROOT=%CCS_INSTALL_ROOT%/ccsv7/tools/compiler/gcc-arm-none-eabi-6-2017-q1-update
set CG_TOOL_ROOT=%CCS_INSTALL_ROOT%/ccsv7/tools/compiler/ti-cgt-arm_16.9.4.LTS
set CMAKE_MAKE_PROGRAM=%CCS_INSTALL_ROOT%/ccsv7/utils/bin/gmake.exe
set STARTERWARE_ROOT=%TI_INSTALL_ROOT%/AM335X_StarterWare_02_00_01_01

rmdir /s /q ..\Release
rmdir /s /q ..\Debug

mkdir ..\Release
mkdir ..\Debug

cd ../Release
cmake -G "Eclipse CDT4 - Unix Makefiles" -DPLATFORM_TYPE=Release -DCCS_INSTALL_ROOT="%CCS_INSTALL_ROOT%" -DARM_GCC_ROOT="%ARM_GCC_ROOT%" -DSTARTERWARE_ROOT="%STARTERWARE_ROOT%" -DCG_TOOL_ROOT="%CG_TOOL_ROOT%" -DCMAKE_MAKE_PROGRAM="%CMAKE_MAKE_PROGRAM%" ..\src
cd ../Debug
cmake -G "Eclipse CDT4 - Unix Makefiles" -DPLATFORM_TYPE=Debug -DCCS_INSTALL_ROOT="%CCS_INSTALL_ROOT%" -DARM_GCC_ROOT="%ARM_GCC_ROOT%" -DSTARTERWARE_ROOT="%STARTERWARE_ROOT%" -DCG_TOOL_ROOT="%CG_TOOL_ROOT%" -DCMAKE_MAKE_PROGRAM="%CMAKE_MAKE_PROGRAM%" ..\src

rem Set up the cmake build environment under Windows, to a clean state

set TI_INSTALL_ROOT=c:/ti
set CCS_INSTALL_ROOT=%TI_INSTALL_ROOT%/ccs730
set ARM_GCC_ROOT=%CCS_INSTALL_ROOT%/ccsv7/tools/compiler/gcc-arm-none-eabi-6-2017-q1-update
set CG_TOOL_ROOT=%CCS_INSTALL_ROOT%/ccsv7/tools/compiler/ti-cgt-arm_16.9.4.LTS
set CMAKE_MAKE_PROGRAM=%CCS_INSTALL_ROOT%/ccsv7/utils/bin/gmake.exe
set STARTERWARE_ROOT=%TI_INSTALL_ROOT%/AM335X_StarterWare_02_00_01_01

rmdir /s /q ..\Release
rmdir /s /q ..\Debug

mkdir ..\Release || goto :error
mkdir ..\Debug || goto :error

cd ../Release
cmake -G "Eclipse CDT4 - Unix Makefiles" -DPLATFORM_TYPE=Release -DCCS_INSTALL_ROOT="%CCS_INSTALL_ROOT%" -DARM_GCC_ROOT="%ARM_GCC_ROOT%" -DSTARTERWARE_ROOT="%STARTERWARE_ROOT%" -DCG_TOOL_ROOT="%CG_TOOL_ROOT%" -DCMAKE_MAKE_PROGRAM="%CMAKE_MAKE_PROGRAM%" ..\src
cd ../Debug
cmake -G "Eclipse CDT4 - Unix Makefiles" -DPLATFORM_TYPE=Debug -DCCS_INSTALL_ROOT="%CCS_INSTALL_ROOT%" -DARM_GCC_ROOT="%ARM_GCC_ROOT%" -DSTARTERWARE_ROOT="%STARTERWARE_ROOT%" -DCG_TOOL_ROOT="%CG_TOOL_ROOT%" -DCMAKE_MAKE_PROGRAM="%CMAKE_MAKE_PROGRAM%" ..\src

cd ../src
goto :end

:error
echo "Setup of cmake failed"

:end

Make setup_cmake.bat abort if there is an error removing the Release or Debug directories, e.g. because a file in one of the directories is locked by an application. This avoids the previous behavior of writing CMake files in the src directory.


set DYNAMO_API=C:\Program Files\Dynamo 0.8
set REVIT_API=C:\Program Files\Autodesk\Revit 2015
set REVIT_VERSION=Revit_2015
"D:\Program Files (x86)\VisualStudio\Common7\IDE\WDExpress.exe" "BecauseWeDynamo.sln"

set DYNAMO_API=C:\Program Files\Dynamo 0.8
set REVIT_API=C:\Program Files\Autodesk\Revit 2016
set REVIT_VERSION=Revit_2016
"C:\Program Files (x86)\VisualStudio\Common7\IDE\WDExpress.exe" "BecauseWeDynamo.sln"

Update test.bat

Update test.bat


echo off
echo PrepForSubmission.bat v1.1 (updated 28 Nov 2013)
echo By Joey Foo (joeyfoo.github.io)
echo -----
echo This batch file is for use on the root directory of a Visual Studio solution,
echo and will copy the current folder out and delete unnecessasary files (\Debug,
echo opensdb, ncb, suo .etc) in preparation for zipping and submission online.
echo.
echo DISCLAIMER: This batch file is provided AS-IS, it's your responsibility
echo to double-check before submission!
echo.
echo ----------

echo.
echo Enter the output directory name (usually your admin number for submission).
set /p outputDir=
echo.
echo Starting...

rmdir ..\%outputDir% /s /q

mkdir ..\%outputDir%
xcopy * ..\%outputDir% /s /c /i

del ..\%outputDir%\*.opensdb /q
del ..\%outputDir%\*.ncb /q
del ..\%outputDir%\*.suo /q
del ..\%outputDir%\*.sdf /q
del ..\%outputDir%\*.user /q

del ..\%outputDir%\.gitignore /q
rmdir ..\%outputDir%\.git /s /q

rmdir ..\%outputDir%\ipch /q

del ..\%outputDir%\*.bat /q

cd ..\%outputDir%
for /d /r . %%d in (Debug,Release) do @if exist "%%d" rd /s /q "%%d"

echo.
echo Completed.
pause

echo off
echo PrepForSubmission.bat v1.1 (updated 28 Nov 2013)
echo By Joey Foo (joeyfoo.github.io)
echo -----
echo This batch file is for use on the root directory of a Visual Studio solution,
echo and will copy the current folder out and delete unnecessasary files (\Debug,
echo opensdb, ncb, suo .etc) in preparation for zipping and submission online.
echo.
echo DISCLAIMER: This batch file is provided AS-IS, it's your responsibility
echo to double-check before submission!
echo.
echo ----------

echo.
echo Enter the output directory name (usually your admin number for submission).
set /p outputDir=
echo.
echo Starting...

rmdir ..\%outputDir% /s /q

mkdir ..\%outputDir%
xcopy * ..\%outputDir% /s /c /i

cd ..\%outputDir%

del *.opensdb /q
del *.ncb /q
del *.suo /q
del *.sdf /q
del *.user /q

del .gitignore /q
rmdir .git /s /q

rmdir ipch /q

del *.bat /q

for /d /r . %%d in (Debug,Release) do @if exist "%%d" rd /s /q "%%d"

echo.
echo Completed.
pause

Update PrepForSubmission.bat

Update PrepForSubmission.bat

I have modified it to change into the desired outputdir and carry out the file removals without having to reference the outputdir repeatedly, not sure if you will like it but well, I am grabbing this code for myself. :P


::*******************************************************************************************************
::  BuildNightly.bat - Gbtc
::
::  Tennessee Valley Authority, 2009
::  No copyright is claimed pursuant to 17 USC  105.  All Other Rights Reserved.
::
::  This software is made freely available under the TVA Open Source Agreement (see below).
::
::  Code Modification History:
::  -----------------------------------------------------------------------------------------------------
::  10/20/2009 - Pinal C. Patel
::       Generated original version of source code.
::  09/14/2010 - Mihir Brahmbhatt
::		 Change Framework path from v3.5 to v4.0
::  10/03/2010 - Pinal C. Patel
::       Updated to use MSBuild 4.0.
::
::*******************************************************************************************************

@ECHO OFF

SetLocal

IF NOT "%1" == "" SET logflag=/l:FileLogger,Microsoft.Build.Engine;logfile=%1

ECHO BuildNightly: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe PDQTracker.buildproj /p:ForceBuild=true %logflag%
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" PDQTracker.buildproj /p:ForceBuild=true %logFlag%

::*******************************************************************************************************
::  BuildNightly.bat - Gbtc
::
::  Tennessee Valley Authority, 2009
::  No copyright is claimed pursuant to 17 USC  105.  All Other Rights Reserved.
::
::  This software is made freely available under the TVA Open Source Agreement (see below).
::
::  Code Modification History:
::  -----------------------------------------------------------------------------------------------------
::  10/20/2009 - Pinal C. Patel
::       Generated original version of source code.
::  09/14/2010 - Mihir Brahmbhatt
::		 Change Framework path from v3.5 to v4.0
::  10/03/2010 - Pinal C. Patel
::       Updated to use MSBuild 4.0.
::
::*******************************************************************************************************

@ECHO OFF

SetLocal

IF NOT "%1" == "" SET logflag=/l:FileLogger,Microsoft.Build.Engine;logfile=%1

ECHO BuildNightly: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe PDQTracker.buildproj /p:ForceBuild=false %logflag%
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" PDQTracker.buildproj /p:ForceBuild=false %logFlag%

Set ForceBuild to false in the BuildNightly.bat script.


@echo off

cd %APPVEYOR_BUILD_FOLDER%

:: =========================================================
:: Set some defaults. Infer some variables.
::
:: These are set globally
if "%LUA_VER%" NEQ "" (
	set LUA=lua
	set LUA_SHORTV=%LUA_VER:~0,3%
) else (
	set LUA=luajit
	set LJ_SHORTV=%LJ_VER:~0,3%
	set LUA_SHORTV=5.1
)

:: defines LUA_DIR so Cmake can find this Lua install
if "%LUA%"=="luajit" (
	set LUA_DIR=c:\lua\%platform%\lj%LJ_SHORTV%
) else (
	set LUA_DIR=c:\lua\%platform%\%LUA_VER%
)

:: Now we declare a scope
Setlocal EnableDelayedExpansion EnableExtensions

set LUAROCKS_SHORTV=%LUAROCKS_VER:~0,3%

if not defined LUAROCKS_URL set LUAROCKS_URL=http://keplerproject.github.io/luarocks/releases
if not defined LUAROCKS_REPO set LUAROCKS_REPO=http://rocks.moonscript.org
if not defined LUA_URL set LUA_URL=http://www.lua.org/ftp
if defined NOCOMPAT (
	set COMPATFLAG=--nocompat
) else (
	set COMPATFLAG=
)
if not defined LUAJIT_GIT_REPO set LUAJIT_GIT_REPO=http://luajit.org/git/luajit-2.0.git
if not defined LUAJIT_URL set LUAJIT_URL=http://luajit.org/download

if not defined LR_EXTERNAL set LR_EXTERNAL=c:\external
if not defined LUAROCKS_INSTALL set LUAROCKS_INSTALL=%LUA_DIR%\LuaRocks
if not defined LR_ROOT set LR_ROOT=%LUAROCKS_INSTALL%\%LUAROCKS_SHORTV%
if not defined LR_SYSTREE set LR_SYSTREE=%LUAROCKS_INSTALL%\systree

if not defined SEVENZIP set SEVENZIP=7z
::
:: =========================================================

:: first create some necessary directories:
mkdir downloads 2>NUL

:: Download and compile Lua (or LuaJIT)
if "%LUA%"=="luajit" (
	if not exist %LUA_DIR% (
		if "%LJ_SHORTV%"=="2.1" (
			:: Clone repository and checkout 2.1 branch
			set lj_source_folder=%APPVEYOR_BUILD_FOLDER%\downloads\luajit-%LJ_VER%
			if not exist !lj_source_folder! (
				echo Cloning git repo %LUAJIT_GIT_REPO% !lj_source_folder!
				git clone %LUAJIT_GIT_REPO% !lj_source_folder! || call :die "Failed to clone repository"
			)
			cd !lj_source_folder!\src
			git checkout v2.1 || call :die
		) else (
			set lj_source_folder=%APPVEYOR_BUILD_FOLDER%\downloads\luajit-%LJ_VER%
			if not exist !lj_source_folder! (
				echo Downloading... %LUAJIT_URL%/LuaJIT-%LJ_VER%.tar.gz
				curl --silent --fail --max-time 120 --connect-timeout 30 %LUAJIT_URL%/LuaJIT-%LJ_VER%.tar.gz | %SEVENZIP% x -si -so -tgzip | %SEVENZIP% x -si -ttar -aoa -odownloads
			)
			cd !lj_source_folder!\src
		)
		:: Compiles LuaJIT
		call msvcbuild.bat

		mkdir %LUA_DIR% 2> NUL
		for %%a in (bin bin\lua bin\lua\jit include lib) do ( mkdir "%LUA_DIR%\%%a" )

		for %%a in (luajit.exe lua51.dll) do ( move "!lj_source_folder!\src\%%a" "%LUA_DIR%\bin" )
		copy "%LUA_DIR%\bin\luajit.exe" "%LUA_DIR%\bin\lua.exe"

		move "!lj_source_folder!\src\lua51.lib" "%LUA_DIR%\lib"
		for %%a in (lauxlib.h lua.h lua.hpp luaconf.h lualib.h luajit.h) do (
			copy "!lj_source_folder!\src\%%a" "%LUA_DIR%\include"
		)

		copy "!lj_source_folder!\src\jit\*.lua" "%LUA_DIR%\bin\lua\jit"

	) else (
		echo LuaJIT %LJ_VER% already installed at %LUA_DIR%
	)
) else (
	if not exist %LUA_DIR% (
		:: Download and compile Lua
		if not exist downloads\lua-%LUA_VER% (
			curl --silent --fail --max-time 120 --connect-timeout 30 %LUA_URL%/lua-%LUA_VER%.tar.gz | %SEVENZIP% x -si -so -tgzip | %SEVENZIP% x -si -ttar -aoa -odownloads
		)

		mkdir downloads\lua-%LUA_VER%\etc 2> NUL
		if not exist downloads\lua-%LUA_VER%\etc\winmake.bat (
			curl --silent --location --insecure --fail --max-time 120 --connect-timeout 30 https://github.com/Tieske/luawinmake/archive/master.tar.gz | %SEVENZIP% x -si -so -tgzip | %SEVENZIP% e -si -ttar -aoa -odownloads\lua-%LUA_VER%\etc luawinmake-master\etc\winmake.bat
		)

		cd downloads\lua-%LUA_VER%
		call etc\winmake %COMPATFLAG%
		call etc\winmake install %LUA_DIR%
	) else (
		echo Lua %LUA_VER% already installed at %LUA_DIR%
	)
)

if not exist %LUA_DIR%\bin\%LUA%.exe call :die "Missing Lua interpreter at %LUA_DIR%\bin\%LUA%.exe"

set PATH=%LUA_DIR%\bin;%PATH%
call !LUA! -v

:: =========================================================
:: LuaRocks
:: =========================================================

if not exist "%LR_ROOT%" (
	:: Downloads and installs LuaRocks
	cd %APPVEYOR_BUILD_FOLDER%

	if not exist downloads\luarocks-%LUAROCKS_VER%-win32.zip (
		echo Downloading LuaRocks...
		curl --silent --fail --max-time 120 --connect-timeout 30 --output downloads\luarocks-%LUAROCKS_VER%-win32.zip %LUAROCKS_URL%/luarocks-%LUAROCKS_VER%-win32.zip
		%SEVENZIP% x -aoa -odownloads downloads\luarocks-%LUAROCKS_VER%-win32.zip
	)

	cd downloads\luarocks-%LUAROCKS_VER%-win32
	call install.bat /LUA %LUA_DIR% /Q /LV %LUA_SHORTV% /P "%LUAROCKS_INSTALL%" /TREE "%LR_SYSTREE%"
)

if not exist "%LR_ROOT%" call :die "LuaRocks not found at %LR_ROOT%"

set PATH=%LR_ROOT%;%LR_SYSTREE%\bin;%PATH%

:: Lua will use just the system rocks
set LUA_PATH=%LR_ROOT%\lua\?.lua;%LR_ROOT%\lua\?\init.lua
set LUA_PATH=%LUA_PATH%;%LR_SYSTREE%\share\lua\%LUA_SHORTV%\?.lua
set LUA_PATH=%LUA_PATH%;%LR_SYSTREE%\share\lua\%LUA_SHORTV%\?\init.lua
set LUA_CPATH=%LR_SYSTREE%\lib\lua\%LUA_SHORTV%\?.dll

call luarocks --version || call :die "Error with LuaRocks installation"
call luarocks list

if not exist "%LR_EXTERNAL%" (
	mkdir "%LR_EXTERNAL%"
	mkdir "%LR_EXTERNAL%\lib"
	mkdir "%LR_EXTERNAL%\include"
)

set PATH=%LR_EXTERNAL%;%PATH%

:: Exports the following variables:
:: (beware of whitespace between & and ^ below)
endlocal & set PATH=%PATH%&^
set LR_SYSTREE=%LR_SYSTREE%&^
set LUA_PATH=%LUA_PATH%&^
set LUA_CPATH=%LUA_CPATH%&^
set LR_EXTERNAL=%LR_EXTERNAL%

echo.
echo ======================================================
if "%LUA%"=="luajit" (
	echo Installation of LuaJIT %LJ_VER% and LuaRocks %LUAROCKS_VER% done.
) else (
	echo Installation of Lua %LUA_VER% and LuaRocks %LUAROCKS_VER% done.
	if defined NOCOMPAT echo Lua was built with compatibility flags disabled.
)
echo Platform         - %platform%
echo LUA              - %LUA%
echo LUA_SHORTV       - %LUA_SHORTV%
echo LJ_SHORTV        - %LJ_SHORTV%
echo LUA_PATH         - %LUA_PATH%
echo LUA_CPATH        - %LUA_CPATH%
echo.
echo LR_EXTERNAL      - %LR_EXTERNAL%
echo ======================================================
echo.

goto :eof

:: This blank space is intentional. If you see errors like "The system cannot find the batch label specified 'foo'"
:: then try adding or removing blank lines lines above.
:: Yes, really.
:: http://stackoverflow.com/questions/232651/why-the-system-cannot-find-the-batch-label-specified-is-thrown-even-if-label-e

:: helper functions:

:: for bailing out when an error occurred
:die %1
echo %1
exit /B 1
goto :eof

@echo off

cd %APPVEYOR_BUILD_FOLDER%

:: =========================================================
:: Set some defaults. Infer some variables.
::
:: These are set globally
if "%LUA_VER%" NEQ "" (
	set LUA=lua
	set LUA_SHORTV=%LUA_VER:~0,3%
) else (
	set LUA=luajit
	set LJ_SHORTV=%LJ_VER:~0,3%
	set LUA_SHORTV=5.1
)

:: defines LUA_DIR so Cmake can find this Lua install
if "%LUA%"=="luajit" (
	set LUA_DIR=c:\lua\%platform%\lj%LJ_SHORTV%
) else (
	set LUA_DIR=c:\lua\%platform%\%LUA_VER%
)

:: Now we declare a scope
Setlocal EnableDelayedExpansion EnableExtensions

set LUAROCKS_SHORTV=%LUAROCKS_VER:~0,3%

if not defined LUAROCKS_URL set LUAROCKS_URL=http://keplerproject.github.io/luarocks/releases
if not defined LUAROCKS_REPO set LUAROCKS_REPO=http://rocks.moonscript.org
if not defined LUA_URL set LUA_URL=http://www.lua.org/ftp
if defined NOCOMPAT (
	set COMPATFLAG=--nocompat
) else (
	set COMPATFLAG=
)
if not defined LUAJIT_GIT_REPO set LUAJIT_GIT_REPO=https://github.com/LuaJIT/LuaJIT.git
if not defined LUAJIT_URL set LUAJIT_URL=https://github.com/LuaJIT/LuaJIT/archive

if not defined LR_EXTERNAL set LR_EXTERNAL=c:\external
if not defined LUAROCKS_INSTALL set LUAROCKS_INSTALL=%LUA_DIR%\LuaRocks
if not defined LR_ROOT set LR_ROOT=%LUAROCKS_INSTALL%\%LUAROCKS_SHORTV%
if not defined LR_SYSTREE set LR_SYSTREE=%LUAROCKS_INSTALL%\systree

if not defined SEVENZIP set SEVENZIP=7z
::
:: =========================================================

:: first create some necessary directories:
mkdir downloads 2>NUL

:: Download and compile Lua (or LuaJIT)
if "%LUA%"=="luajit" (
	if not exist %LUA_DIR% (
		if "%LJ_SHORTV%"=="2.1" (
			:: Clone repository and checkout 2.1 branch
			set lj_source_folder=%APPVEYOR_BUILD_FOLDER%\downloads\luajit-%LJ_VER%
			if not exist !lj_source_folder! (
				echo Cloning git repo %LUAJIT_GIT_REPO% !lj_source_folder!
				git clone %LUAJIT_GIT_REPO% !lj_source_folder! || call :die "Failed to clone repository"
			)
			cd !lj_source_folder!\src
			git checkout v2.1 || call :die
		) else (
			set lj_source_folder=%APPVEYOR_BUILD_FOLDER%\downloads\luajit-%LJ_VER%
			if not exist !lj_source_folder! (
				echo Downloading... %LUAJIT_URL%/v%LJ_VER%.tar.gz
				curl --location --silent --fail --max-time 120 --connect-timeout 30 %LUAJIT_URL%/v%LJ_VER%.tar.gz | %SEVENZIP% x -si -so -tgzip | %SEVENZIP% x -si -ttar -aoa -odownloads
			)
			cd !lj_source_folder!\src
		)
		:: Compiles LuaJIT
		call msvcbuild.bat

		mkdir %LUA_DIR% 2> NUL
		for %%a in (bin bin\lua bin\lua\jit include lib) do ( mkdir "%LUA_DIR%\%%a" )

		for %%a in (luajit.exe lua51.dll) do ( move "!lj_source_folder!\src\%%a" "%LUA_DIR%\bin" )
		copy "%LUA_DIR%\bin\luajit.exe" "%LUA_DIR%\bin\lua.exe"

		move "!lj_source_folder!\src\lua51.lib" "%LUA_DIR%\lib"
		for %%a in (lauxlib.h lua.h lua.hpp luaconf.h lualib.h luajit.h) do (
			copy "!lj_source_folder!\src\%%a" "%LUA_DIR%\include"
		)

		copy "!lj_source_folder!\src\jit\*.lua" "%LUA_DIR%\bin\lua\jit"

	) else (
		echo LuaJIT %LJ_VER% already installed at %LUA_DIR%
	)
) else (
	if not exist %LUA_DIR% (
		:: Download and compile Lua
		if not exist downloads\lua-%LUA_VER% (
			curl --silent --fail --max-time 120 --connect-timeout 30 %LUA_URL%/lua-%LUA_VER%.tar.gz | %SEVENZIP% x -si -so -tgzip | %SEVENZIP% x -si -ttar -aoa -odownloads
		)

		mkdir downloads\lua-%LUA_VER%\etc 2> NUL
		if not exist downloads\lua-%LUA_VER%\etc\winmake.bat (
			curl --silent --location --insecure --fail --max-time 120 --connect-timeout 30 https://github.com/Tieske/luawinmake/archive/master.tar.gz | %SEVENZIP% x -si -so -tgzip | %SEVENZIP% e -si -ttar -aoa -odownloads\lua-%LUA_VER%\etc luawinmake-master\etc\winmake.bat
		)

		cd downloads\lua-%LUA_VER%
		call etc\winmake %COMPATFLAG%
		call etc\winmake install %LUA_DIR%
	) else (
		echo Lua %LUA_VER% already installed at %LUA_DIR%
	)
)

if not exist %LUA_DIR%\bin\%LUA%.exe call :die "Missing Lua interpreter at %LUA_DIR%\bin\%LUA%.exe"

set PATH=%LUA_DIR%\bin;%PATH%
call !LUA! -v

:: =========================================================
:: LuaRocks
:: =========================================================

if not exist "%LR_ROOT%" (
	:: Downloads and installs LuaRocks
	cd %APPVEYOR_BUILD_FOLDER%

	if not exist downloads\luarocks-%LUAROCKS_VER%-win32.zip (
		echo Downloading LuaRocks...
		curl --silent --fail --max-time 120 --connect-timeout 30 --output downloads\luarocks-%LUAROCKS_VER%-win32.zip %LUAROCKS_URL%/luarocks-%LUAROCKS_VER%-win32.zip
		%SEVENZIP% x -aoa -odownloads downloads\luarocks-%LUAROCKS_VER%-win32.zip
	)

	cd downloads\luarocks-%LUAROCKS_VER%-win32
	call install.bat /LUA %LUA_DIR% /Q /LV %LUA_SHORTV% /P "%LUAROCKS_INSTALL%" /TREE "%LR_SYSTREE%"
)

if not exist "%LR_ROOT%" call :die "LuaRocks not found at %LR_ROOT%"

set PATH=%LR_ROOT%;%LR_SYSTREE%\bin;%PATH%

:: Lua will use just the system rocks
set LUA_PATH=%LR_ROOT%\lua\?.lua;%LR_ROOT%\lua\?\init.lua
set LUA_PATH=%LUA_PATH%;%LR_SYSTREE%\share\lua\%LUA_SHORTV%\?.lua
set LUA_PATH=%LUA_PATH%;%LR_SYSTREE%\share\lua\%LUA_SHORTV%\?\init.lua
set LUA_CPATH=%LR_SYSTREE%\lib\lua\%LUA_SHORTV%\?.dll

call luarocks --version || call :die "Error with LuaRocks installation"
call luarocks list

if not exist "%LR_EXTERNAL%" (
	mkdir "%LR_EXTERNAL%"
	mkdir "%LR_EXTERNAL%\lib"
	mkdir "%LR_EXTERNAL%\include"
)

set PATH=%LR_EXTERNAL%;%PATH%

:: Exports the following variables:
:: (beware of whitespace between & and ^ below)
endlocal & set PATH=%PATH%&^
set LR_SYSTREE=%LR_SYSTREE%&^
set LUA_PATH=%LUA_PATH%&^
set LUA_CPATH=%LUA_CPATH%&^
set LR_EXTERNAL=%LR_EXTERNAL%

echo.
echo ======================================================
if "%LUA%"=="luajit" (
	echo Installation of LuaJIT %LJ_VER% and LuaRocks %LUAROCKS_VER% done.
) else (
	echo Installation of Lua %LUA_VER% and LuaRocks %LUAROCKS_VER% done.
	if defined NOCOMPAT echo Lua was built with compatibility flags disabled.
)
echo Platform         - %platform%
echo LUA              - %LUA%
echo LUA_SHORTV       - %LUA_SHORTV%
echo LJ_SHORTV        - %LJ_SHORTV%
echo LUA_PATH         - %LUA_PATH%
echo LUA_CPATH        - %LUA_CPATH%
echo.
echo LR_EXTERNAL      - %LR_EXTERNAL%
echo ======================================================
echo.

goto :eof

:: This blank space is intentional. If you see errors like "The system cannot find the batch label specified 'foo'"
:: then try adding or removing blank lines lines above.
:: Yes, really.
:: http://stackoverflow.com/questions/232651/why-the-system-cannot-find-the-batch-label-specified-is-thrown-even-if-label-e

:: helper functions:

:: for bailing out when an error occurred
:die %1
echo %1
exit /B 1
goto :eof

use GitHub mirror of LuaJIT

appveyor: use GitHub mirror of LuaJIT

See http://www.freelists.org/post/luajit/luajit-git-is-not-accessible-from-Travis-CI


cd C:\Users\Elaine\Documents\BKL\Lowell\2016-2017\TableauFormat
del Enrollment.csv
del ProcessedAttend.csv
del ProcessedEnroll.csv
del DistrictAttend.csv
del PublicAttend.csv

cd C:\Users\Elaine\Documents\BKL\Lowell\2016-2017\Scripts
python EnrollTableCreate.py
python ProcessAttendance.py
python ProcessEnrollment.py

cd C:\Users\Elaine\Documents\BKL\Lowell\2016-2017\TableauFormat
type ProcessedAttend.csv, ProcessedEnroll.csv > DistrictAttend.csv

cd C:\Users\Elaine\Documents\BKL\Lowell\2016-2017\Scripts
python ProcPublicView.py
python ProcStudentView.py

Add files via upload

Add files via upload

add district view to public view


@echo off
SETLOCAL

for %%x in (%cmdcmdline%) do if %%~x==/c set DOUBLECLICKED=1

:: set path to erlang installation
call "%~dp0"\bin\find_erlang.bat

::replace @EMAKEFILEDEFINES@ from Emakefile.in and write Emakefile
::(this is what autoconf on *nix would do)
:: depending on your config, you might need to add one or more of the following options:
::  {d, have_toke}
::  {d, have_ctline_support}
::  {d, have_callback_support}
::  {d, with_crypto_hash}
:: refer to configure.ac for the appropriate checks for necessity
::if yaws should use the file:sendfile/5 functionality, set @YAWS_OPTIONS@ to
::  {d, 'HAVE_ERLANG_SENDFILE'}
::but note the issues in R15 & R16 mentioned at http://erlang.org/pipermail/erlang-questions/2013-October/075676.html
:: Note: Search & Replace functionality from http://www.dostips.com
if not exist Emakefile (
    echo Creating Emakefile...
    for /f "tokens=1,* delims=&&&" %%a in (Emakefile.in) do (
        set "line=%%a"
        if defined line (
            call set "line=echo.%%line:  @EMAKEFILEDEFINES@=%%"
            for /f "delims=" %%X in ('"echo."%%line%%""') do %%~X >> Emakefile
        ) ELSE echo.
    )
    echo ...done!
)

@echo on
pushd "%~dp0""\contrib\log4erl\src"
%ERLANG_HOME%\bin\erlc.exe log4erl_parser.yrl
%ERLANG_HOME%\bin\erl.exe -noinput -noshell -s leex file log4erl_lex.xrl -s init stop
popd
%ERLANG_HOME%\bin\erl.exe -pa contrib\yaws -pa ebin -noinput +B -eval "case make:all() of up_to_date -> halt(0); error -> halt(1) end."
@echo off

if defined DOUBLECLICKED PAUSE

@echo off
SETLOCAL

for %%x in (%cmdcmdline%) do if %%~x==/c set DOUBLECLICKED=1

:: set path to erlang installation
call "%~dp0"\bin\find_erlang.bat

::replace @EMAKEFILEDEFINES@ from Emakefile.in and write Emakefile
::(this is what autoconf on *nix would do)
:: depending on your config, you might need to add one or more of the following options:
::  {d, have_toke}
::  {d, have_ctline_support}
::  {d, have_callback_support}
::  {d, with_crypto_hash}
:: refer to configure.ac for the appropriate checks for necessity
::if yaws should use the file:sendfile/5 functionality, set @YAWS_OPTIONS@ to
::  {d, 'HAVE_ERLANG_SENDFILE'}
::but note the issues in R15 & R16 mentioned at http://erlang.org/pipermail/erlang-questions/2013-October/075676.html
:: Note: Search & Replace functionality from http://www.dostips.com
if not exist Emakefile (
    echo Creating Emakefile...
    for /f "tokens=1,* delims=&&&" %%a in (Emakefile.in) do (
        set "line=%%a"
        if defined line (
            call set "line=echo.%%line:  @EMAKEFILEDEFINES@=%%"
            call set "line=%%line:  @YAWS_OPTIONS@=%%"
            for /f "delims=" %%X in ('"echo."%%line%%""') do %%~X >> Emakefile
        ) ELSE echo.
    )
    echo ...done!
)

@echo on
pushd "%~dp0""\contrib\log4erl\src"
%ERLANG_HOME%\bin\erlc.exe log4erl_parser.yrl
%ERLANG_HOME%\bin\erl.exe -noinput -noshell -s leex file log4erl_lex.xrl -s init stop
popd
%ERLANG_HOME%\bin\erl.exe -pa contrib\yaws -pa ebin -noinput +B -eval "case make:all() of up_to_date -> halt(0); error -> halt(1) end."
@echo off

if defined DOUBLECLICKED PAUSE

windows: remove YAWS_OPTIONS from the generated Emakefile


set SRC_X86_DEBUG=Win32\Debug\
set SRC_X86_RELEASE=Win32\Release\
set SRC_X64_DEBUG=x64\Debug\
set SRC_X64_RELEASE=x64\Release\
set SRC_SAMPLE_DATA=sampledata\
set DOC_DIR=doc\
set DIST_DIR=dist\
set DIST_TIMESTAMP=%DIST_DIR%buildtime.txt
set DIST_SAMPLE_DIR=%DIST_DIR%sample\
set DIST_DOC_DIR=%DIST_DIR%doc\

rem clean dist
rmdir /S /Q %DIST_DIR%

rem build
call "%VS140COMNTOOLS%vsvars32.bat"
devenv Qol.sln /build "Debug|x86"
if ERRORLEVEL 1 goto :END
devenv Qol.sln /build "Debug|x64"
if ERRORLEVEL 1 goto :END
devenv Qol.sln /build "Release|x86"
if ERRORLEVEL 1 goto :END
devenv Qol.sln /build "Release|x64"
if ERRORLEVEL 1 goto :END

rem doc
pushd %DOC_DIR%
call doc.bat
if ERRORLEVEL 1 goto :END
popd

rem mkdir
mkdir %DIST_DIR%
mkdir %DIST_SAMPLE_DIR%App
mkdir %DIST_DOC_DIR%html

rem date, time
echo %date% %time% > %DIST_TIMESTAMP%

rem copy
xcopy %SRC_X86_RELEASE%App.exe %DIST_SAMPLE_DIR%App
xcopy %SRC_X86_RELEASE%App.pdb %DIST_SAMPLE_DIR%App
xcopy %SRC_X86_RELEASE%*.cso %DIST_SAMPLE_DIR%App
xcopy /S %SRC_SAMPLE_DATA%* %DIST_SAMPLE_DIR%sampledata\
xcopy /S %DOC_DIR%html %DIST_DOC_DIR%html

:END
pause

set SRC_X86_DEBUG=Win32\Debug\
set SRC_X86_RELEASE=Win32\Release\
set SRC_X64_DEBUG=x64\Debug\
set SRC_X64_RELEASE=x64\Release\
set SRC_SAMPLE_DATA=sampledata\
set DOC_DIR=doc\
set DIST_DIR=dist\
set DIST_TIMESTAMP=%DIST_DIR%buildtime.txt
set DIST_SAMPLE_DIR=%DIST_DIR%sample\
set DIST_DOC_DIR=%DIST_DIR%doc\

rem clean dist
rmdir /S /Q %DIST_DIR%

rem build
call "%VS140COMNTOOLS%vsvars32.bat"
devenv Qol.sln /build "Debug|x86"
if ERRORLEVEL 1 goto :END
devenv Qol.sln /build "Debug|x64"
if ERRORLEVEL 1 goto :END
devenv Qol.sln /build "Release|x86"
if ERRORLEVEL 1 goto :END
devenv Qol.sln /build "Release|x64"
if ERRORLEVEL 1 goto :END

rem doc
pushd %DOC_DIR%
call doc.bat
if ERRORLEVEL 1 goto :END
popd

rem mkdir
mkdir %DIST_DIR%
mkdir %DIST_SAMPLE_DIR%App
mkdir %DIST_DOC_DIR%html

rem date, time
echo %date% %time% > %DIST_TIMESTAMP%

rem copy
xcopy %SRC_X86_RELEASE%App.exe %DIST_SAMPLE_DIR%App
xcopy %SRC_X86_RELEASE%App.pdb %DIST_SAMPLE_DIR%App
xcopy %SRC_X86_RELEASE%App.map %DIST_SAMPLE_DIR%App
xcopy %SRC_X86_RELEASE%*.cso %DIST_SAMPLE_DIR%App
xcopy /S %SRC_SAMPLE_DATA%* %DIST_SAMPLE_DIR%sampledata\
xcopy /S %DOC_DIR%html %DIST_DOC_DIR%html

:END
pause

Copy map file to dist

Copy map file to dist


@echo off

cd ..\builder
build "" chrlauncher 2.6

@echo off

cd ..\builder
build "" chrlauncher 2.5

fix version

fix version


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

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

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

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

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

shift
goto :argLoop

:build

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

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

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

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

::Done
goto :EOF

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

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

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

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

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

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

shift
goto :argLoop

:build

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

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

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

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

::Done
goto :EOF

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

Add windows build script changes.

Add windows build script changes.


@echo off
setlocal EnableDelayedExpansion

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

:: Default to highest Visual Studio version available
set __VSVersion=vs2015

if defined VS120COMNTOOLS set __VSVersion=vs2013
if defined VS140COMNTOOLS set __VSVersion=vs2015

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

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

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

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

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

if /i "%1" == "vs2013" (set __VSVersion=%1&shift&goto Arg_Loop)
if /i "%1" == "vs2015" (set __VSVersion=%1&shift&goto Arg_Loop)
if /i "%1" == "skiptestbuild" (set __SkipTestBuild=1&shift&goto Arg_Loop)
if /i "%1" == "docrossgen" (set __DoCrossgen=1&shift&goto Arg_Loop)

echo Invalid commandline argument: %1
goto Usage

:ArgsDone

echo Commencing CoreCLR Repo build
echo.

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

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

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

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

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

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

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

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

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

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

goto CheckVS

:CheckVS

set __VSProductVersion=
if /i "%__VSVersion%" == "vs2013" set __VSProductVersion=120
if /i "%__VSVersion%" == "vs2015" set __VSProductVersion=140

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

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

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

:: All set to commence the build

setlocal
if defined __MscorlibOnly goto PerformMScorlibBuild

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

rem arm64 builds currently use private toolset which has not been released yet
if /i "%__BuildArch%" =="arm64" goto GenVSSolution

:: Set the environment for the native build
set __VCBuildArch=x86_amd64
if /i "%__BuildArch%" == "x86" (set __VCBuildArch=x86)
call "!VS%__VSProductVersion%COMNTOOLS!\..\..\VC\vcvarsall.bat" %__VCBuildArch%

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

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

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

REM Build CoreCLR
:BuildCoreCLR
set "__CoreCLRBuildLog=%__LogsDir%\CoreCLR_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
if /i "%__BuildArch%" == "arm64" (
  REM TODO, remove once we have msbuild support for this platform.

  %_msbuildexe% "%__IntermediatesDir%\install.vcxproj" %__MSBCleanBuildArgs% /nologo /maxcpucount /nodeReuse:false /p:Configuration=%__BuildType% /p:UseEnv=true /fileloggerparameters:Verbosity=normal;LogFile="%__CoreCLRBuildLog%"
) else (
  %_msbuildexe% "%__IntermediatesDir%\install.vcxproj" %__MSBCleanBuildArgs% /nologo /maxcpucount /nodeReuse:false /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% /fileloggerparameters:Verbosity=normal;LogFile="%__CoreCLRBuildLog%"
)
IF NOT ERRORLEVEL 1 goto PerformMScorlibBuild
echo Native component build failed. Refer !__CoreCLRBuildLog! for details.
exit /b 1

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

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

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

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

if /i "%__BuildArch%" =="arm64" set __AdditionalMSBuildArgs=/p:BuildNugetPackage=false

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

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

:CrossGenMscorlib
if /i "%__BuildArch%" == "x86" (
  if not defined __DoCrossgen (
    echo Skipping Crossgen
    goto PerformTestBuild
  )
)

if /i "%__BuildArch%" == "arm64" (
  if not defined __DoCrossgen (
    echo Skipping Crossgen
    goto PerformTestBuild
  )
)

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

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

:PerformTestBuild
if defined __SkipTestBuild (
    echo Skipping test build
    goto SuccessfulBuild
)
echo.
echo Commencing build of tests for %__BuildOS%.%__BuildArch%.%__BuildType%
echo.
call %__ProjectDir%\tests\buildtest.cmd
IF NOT ERRORLEVEL 1 goto SuccessfulBuild
echo Test binaries build failed. Refer !__TestManagedBuildLog! for details.
exit /b 1

:SuccessfulBuild
::Build complete
echo Repo successfully built.
echo.
echo Product binaries are available at !__BinDir!
if not defined __SkipTestBuild (
    echo Test binaries are available at !__TestBinDir!
)
exit /b 0

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

@echo off
setlocal EnableDelayedExpansion

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

:: Default to highest Visual Studio version available
set __VSVersion=vs2015

if defined VS120COMNTOOLS set __VSVersion=vs2013
if defined VS140COMNTOOLS set __VSVersion=vs2015

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

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

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

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

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

if /i "%1" == "vs2013" (set __VSVersion=%1&shift&goto Arg_Loop)
if /i "%1" == "vs2015" (set __VSVersion=%1&shift&goto Arg_Loop)
if /i "%1" == "skiptestbuild" (set __SkipTestBuild=1&shift&goto Arg_Loop)
if /i "%1" == "docrossgen" (set __DoCrossgen=1&shift&goto Arg_Loop)

if /i "%1" == "/toolset_dir" (set __ToolsetDir=%2&shift&shift&goto Arg_Loop)

echo Invalid commandline argument: %1
goto Usage

:ArgsDone

echo Commencing CoreCLR Repo build
echo.

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

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

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

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

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

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

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

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

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

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

goto CheckVS

:CheckVS

set __VSProductVersion=
if /i "%__VSVersion%" == "vs2013" set __VSProductVersion=120
if /i "%__VSVersion%" == "vs2015" set __VSProductVersion=140

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

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

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

:: All set to commence the build

setlocal EnableDelayedExpansion
if defined __MscorlibOnly goto PerformMScorlibBuild

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

rem arm64 builds currently use private toolset which has not been released yet
if /i "%__BuildArch%" == "arm64"  (
  REM TODO, remove once the toolset is open.

  if not "%__BuildOS%" == "Windows_NT" goto GenVSSolution

  if /i "%__ToolsetDir%" == "" (
    echo "A toolset directory is required for the Arm64 Windows build."
    exit /b 1
  )
)

REM TODO, remove once the toolset is open.
if /i "%__BuildArch%" == "arm64" set PATH=%PATH%;%__ToolsetDir%\cpp\bin
if /i "%__BuildArch%" == "arm64" set LIB=%__ToolsetDir%\OS\lib
if /i "%__BuildArch%" == "arm64" set INCLUDE="%__ToolsetDir%\cpp\inc;%__ToolsetDir%\OS\inc\Windows;%__ToolsetDir%\OS\inc\Windows\crt;%__ToolsetDir%\cpp\inc\vc;%__ToolsetDir%\OS\inc\win8"

if /i "%__BuildArch%" == "arm64" goto GenVSSolution

:: Set the environment for the native build
set __VCBuildArch=x86_amd64
if /i "%__BuildArch%" == "x86" (set __VCBuildArch=x86)
call "!VS%__VSProductVersion%COMNTOOLS!\..\..\VC\vcvarsall.bat" %__VCBuildArch%

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

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

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

REM Build CoreCLR
:BuildCoreCLR
set "__CoreCLRBuildLog=%__LogsDir%\CoreCLR_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
if /i "%__BuildArch%" == "arm64" (
  REM TODO, remove once we have msbuild support for this platform.

  %_msbuildexe% "%__IntermediatesDir%\install.vcxproj" %__MSBCleanBuildArgs% /nologo /maxcpucount /nodeReuse:false /p:Configuration=%__BuildType% /p:UseEnv=true /fileloggerparameters:Verbosity=normal;LogFile="%__CoreCLRBuildLog%"
) else (
  %_msbuildexe% "%__IntermediatesDir%\install.vcxproj" %__MSBCleanBuildArgs% /nologo /maxcpucount /nodeReuse:false /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% /fileloggerparameters:Verbosity=normal;LogFile="%__CoreCLRBuildLog%"
)
IF NOT ERRORLEVEL 1 goto PerformMScorlibBuild
echo Native component build failed. Refer !__CoreCLRBuildLog! for details.
exit /b 1

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

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

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

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

if /i "%__BuildArch%" =="arm64" set __AdditionalMSBuildArgs=/p:BuildNugetPackage=false

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

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

:CrossGenMscorlib
if /i "%__BuildArch%" == "x86" (
  if not defined __DoCrossgen (
    echo Skipping Crossgen
    goto PerformTestBuild
  )
)

if /i "%__BuildArch%" == "arm64" (
  if not defined __DoCrossgen (
    echo Skipping Crossgen
    goto PerformTestBuild
  )
)

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

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

:PerformTestBuild
if defined __SkipTestBuild (
    echo Skipping test build
    goto SuccessfulBuild
)
echo.
echo Commencing build of tests for %__BuildOS%.%__BuildArch%.%__BuildType%
echo.
call %__ProjectDir%\tests\buildtest.cmd
IF NOT ERRORLEVEL 1 goto SuccessfulBuild
echo Test binaries build failed. Refer !__TestManagedBuildLog! for details.
exit /b 1

:SuccessfulBuild
::Build complete
echo Repo successfully built.
echo.
echo Product binaries are available at !__BinDir!
if not defined __SkipTestBuild (
    echo Test binaries are available at !__TestBinDir!
)
exit /b 0

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

Set up path for toolset.

Set up path for toolset.


@echo off

pushd %~dp0
set "KRE_NUGET_API_URL=https://www.nuget.org/api/v2"
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.ps1'))"

set PATH=%PATH%;%userprofile%\.k\bin
set KRE_HOME=%USERPROFILE%\.k

call kvm install 1.0.0-beta3
call kvm use 1.0.0-beta3
rem set the runtime path because the above commands set \.k<space>\runtimes
set PATH=%USERPROFILE%\.k\runtimes\kre-clr-win-x86.1.0.0-beta3\bin;%PATH%
call kpm restore
cd tests\OmniSharp.Tests
call k test
cd ..\OmniSharp.Stdio.Tests
call k test
cd ..\..
call kpm bundle src\OmniSharp --no-source --out artifacts\build\omnisharp --runtime kre-clr-win-x86.1.0.0-beta3

popd

@echo off

pushd %~dp0
set "KRE_NUGET_API_URL=https://www.nuget.org/api/v2"
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.ps1'))"

set PATH=%PATH%;%userprofile%\.k\bin
set KRE_HOME=%USERPROFILE%\.k

call kvm install 1.0.0-beta3
call kvm use 1.0.0-beta3
rem set the runtime path because the above commands set \.k<space>\runtimes
set PATH=%USERPROFILE%\.k\runtimes\kre-clr-win-x86.1.0.0-beta3\bin;%PATH%
call kpm restore
if %errorlevel% neq 0 exit /b %errorlevel%
cd tests\OmniSharp.Tests
call k test
if %errorlevel% neq 0 exit /b %errorlevel%
cd ..\OmniSharp.Stdio.Tests
call k test
if %errorlevel% neq 0 exit /b %errorlevel%
cd ..\..
call kpm bundle src\OmniSharp --no-source --out artifacts\build\omnisharp --runtime kre-clr-win-x86.1.0.0-beta3

popd

exit on error

exit on error


@echo off

if %1.==. goto usage

set arg1=%1

:: strip off relative path
if "%arg1:~0,3%" == "..\" set arg1=%arg1:~3%

set startdir=%cd%
cd "%~dp0"

echo --- amd_lib ---
cd ..\amd_lib\shared\d3d11\premake
call :createvsfilesincluding2010
call :createvsfileswithminimaldependencies

echo --- amd_sdk ---
cd ..\..\..\..\framework\d3d11\amd_sdk\premake
call :createvsfilesincluding2010
call :createvsfileswithminimaldependencies

echo --- dxut core ---
cd ..\..\dxut\Core
call :createvsfilesincluding2010

echo --- dxut optional ---
cd ..\..\..\..\framework\d3d11\dxut\Optional
call :createvsfilesincluding2010

echo --- dx12u ---
cd ..\..\..\d3d12\dx12u\premake
call :createvsfiles12_b

echo --- gu ---
cd ..\..\gu\premake
call :createvsfiles12_b
cd ..\..\..\..\
:: we don't keep solution files for amd_lib, amd_sdk, dxut, etc.
call :cleanslnfiles

echo --- %arg1% ---
cd %arg1%\premake
call :createvsfiles
call :createvsfiles12_a
cd ..\..\

:: sample, capture_viewer, etc.
for /f %%a in ('dir /a:d /b %arg1%_* 2^>nul') do call :createvsfilesforsamples %%a
for /f %%a in ('dir /a:d /b %arg1%11_* 2^>nul') do call :createvsfilesforsamples %%a
for /f %%a in ('dir /a:d /b %arg1%12_* 2^>nul') do call :createvsfilesforsamples12 %%a

cd "%startdir%"

goto :EOF

::--------------------------
:: SUBROUTINES
::--------------------------

:: sample, capture_viewer, etc.
:createvsfilesforsamples
if exist %1\premake (
    echo --- %1 ---
    cd %1\premake
    call :createvsfiles
    cd ..\..\
)
goto :EOF

:: sample, capture_viewer, etc.
:createvsfilesforsamples12
if exist %1\premake (
    echo --- %1 ---
    cd %1\premake
    ..\..\premake\premake5.exe vs2015
    cd ..\..\
)
goto :EOF

:: run premake for vs2012, vs2013, and vs2015
:createvsfiles
..\..\premake\premake5.exe vs2012
..\..\premake\premake5.exe vs2013
..\..\premake\premake5.exe vs2015
goto :EOF

:: run premake for vs2015 for d3d12
:createvsfiles12_a
..\..\premake\premake5.exe --file=premake5_d3d12.lua vs2015
goto :EOF

:: run premake for vs2015 for d3d12
:createvsfiles12_b
..\..\..\..\premake\premake5.exe vs2015
goto :EOF

:: run premake for vs2010, vs2012, vs2013, and vs2015
:createvsfilesincluding2010
..\..\..\..\premake\premake5.exe vs2010
..\..\..\..\premake\premake5.exe vs2012
..\..\..\..\premake\premake5.exe vs2013
..\..\..\..\premake\premake5.exe vs2015
goto :EOF

:: run premake for vs2010, vs2012, vs2013, and vs2015
:createvsfileswithminimaldependencies
..\..\..\..\premake\premake5.exe --file=premake5_minimal.lua vs2010
..\..\..\..\premake\premake5.exe --file=premake5_minimal.lua vs2012
..\..\..\..\premake\premake5.exe --file=premake5_minimal.lua vs2013
..\..\..\..\premake\premake5.exe --file=premake5_minimal.lua vs2015
goto :EOF

:: delete unnecessary sln files
:cleanslnfiles
del /f /q amd_lib\shared\d3d11\build\AMD_LIB_2010.sln
del /f /q amd_lib\shared\d3d11\build\AMD_LIB_2012.sln
del /f /q amd_lib\shared\d3d11\build\AMD_LIB_2013.sln
del /f /q amd_lib\shared\d3d11\build\AMD_LIB_2015.sln

del /f /q amd_lib\shared\d3d11\build\AMD_LIB_Minimal_2010.sln
del /f /q amd_lib\shared\d3d11\build\AMD_LIB_Minimal_2012.sln
del /f /q amd_lib\shared\d3d11\build\AMD_LIB_Minimal_2013.sln
del /f /q amd_lib\shared\d3d11\build\AMD_LIB_Minimal_2015.sln

del /f /q framework\d3d11\amd_sdk\build\AMD_SDK_2010.sln
del /f /q framework\d3d11\amd_sdk\build\AMD_SDK_2012.sln
del /f /q framework\d3d11\amd_sdk\build\AMD_SDK_2013.sln
del /f /q framework\d3d11\amd_sdk\build\AMD_SDK_2015.sln

del /f /q framework\d3d11\amd_sdk\build\AMD_SDK_Minimal_2010.sln
del /f /q framework\d3d11\amd_sdk\build\AMD_SDK_Minimal_2012.sln
del /f /q framework\d3d11\amd_sdk\build\AMD_SDK_Minimal_2013.sln
del /f /q framework\d3d11\amd_sdk\build\AMD_SDK_Minimal_2015.sln

del /f /q framework\d3d11\dxut\Core\DXUT_2010.sln
del /f /q framework\d3d11\dxut\Core\DXUT_2012.sln
del /f /q framework\d3d11\dxut\Core\DXUT_2013.sln
del /f /q framework\d3d11\dxut\Core\DXUT_2015.sln

del /f /q framework\d3d11\dxut\Optional\DXUTOpt_2010.sln
del /f /q framework\d3d11\dxut\Optional\DXUTOpt_2012.sln
del /f /q framework\d3d11\dxut\Optional\DXUTOpt_2013.sln
del /f /q framework\d3d11\dxut\Optional\DXUTOpt_2015.sln

del /f /q framework\d3d12\dx12u\build\dx12u_2015.sln
del /f /q framework\d3d12\gu\build\gu_2015.sln
goto :EOF

::--------------------------
:: usage should be last
::--------------------------

:usage
echo   usage: %0 library_dir_name
echo      or: %0 ..\library_dir_name
echo example: %0 AMD_AOFX
echo      or: %0 ..\AMD_AOFX

@echo off

if %1.==. goto usage

set arg1=%1

:: strip off relative path
if "%arg1:~0,3%" == "..\" set arg1=%arg1:~3%

set startdir=%cd%
cd "%~dp0"

echo --- amd_lib ---
cd ..\amd_lib\shared\d3d11\premake
call :createvsfilesincluding2010
call :createvsfileswithminimaldependencies

echo --- amd_sdk ---
cd ..\..\..\..\framework\d3d11\amd_sdk\premake
call :createvsfilesincluding2010
call :createvsfileswithminimaldependencies

echo --- dxut core ---
cd ..\..\dxut\Core
call :createvsfilesincluding2010

echo --- dxut optional ---
cd ..\Optional
call :createvsfilesincluding2010

echo --- dx12u ---
cd ..\..\..\d3d12\dx12u\premake
call :createvsfiles12_b

echo --- gu ---
cd ..\..\gu\premake
call :createvsfiles12_b
cd ..\..\..\..\
:: we don't keep solution files for amd_lib, amd_sdk, dxut, etc.
call :cleanslnfiles

echo --- %arg1% ---
cd %arg1%\premake
call :createvsfiles
call :createvsfiles12_a
cd ..\..\

:: sample, capture_viewer, etc.
for /f %%a in ('dir /a:d /b %arg1%_* 2^>nul') do call :createvsfilesforsamples %%a
for /f %%a in ('dir /a:d /b %arg1%11_* 2^>nul') do call :createvsfilesforsamples %%a
for /f %%a in ('dir /a:d /b %arg1%12_* 2^>nul') do call :createvsfilesforsamples12 %%a

cd "%startdir%"

goto :EOF

::--------------------------
:: SUBROUTINES
::--------------------------

:: sample, capture_viewer, etc.
:createvsfilesforsamples
if exist %1\premake (
    echo --- %1 ---
    cd %1\premake
    call :createvsfiles
    cd ..\..\
)
goto :EOF

:: sample, capture_viewer, etc.
:createvsfilesforsamples12
if exist %1\premake (
    echo --- %1 ---
    cd %1\premake
    ..\..\premake\premake5.exe vs2015
    cd ..\..\
)
goto :EOF

:: run premake for vs2012, vs2013, and vs2015
:createvsfiles
..\..\premake\premake5.exe vs2012
..\..\premake\premake5.exe vs2013
..\..\premake\premake5.exe vs2015
goto :EOF

:: run premake for vs2015 for d3d12
:createvsfiles12_a
..\..\premake\premake5.exe --file=premake5_d3d12.lua vs2015
goto :EOF

:: run premake for vs2015 for d3d12
:createvsfiles12_b
..\..\..\..\premake\premake5.exe vs2015
goto :EOF

:: run premake for vs2010, vs2012, vs2013, and vs2015
:createvsfilesincluding2010
..\..\..\..\premake\premake5.exe vs2010
..\..\..\..\premake\premake5.exe vs2012
..\..\..\..\premake\premake5.exe vs2013
..\..\..\..\premake\premake5.exe vs2015
goto :EOF

:: run premake for vs2010, vs2012, vs2013, and vs2015
:createvsfileswithminimaldependencies
..\..\..\..\premake\premake5.exe --file=premake5_minimal.lua vs2010
..\..\..\..\premake\premake5.exe --file=premake5_minimal.lua vs2012
..\..\..\..\premake\premake5.exe --file=premake5_minimal.lua vs2013
..\..\..\..\premake\premake5.exe --file=premake5_minimal.lua vs2015
goto :EOF

:: delete unnecessary sln files
:cleanslnfiles
del /f /q amd_lib\shared\d3d11\build\AMD_LIB_2010.sln
del /f /q amd_lib\shared\d3d11\build\AMD_LIB_2012.sln
del /f /q amd_lib\shared\d3d11\build\AMD_LIB_2013.sln
del /f /q amd_lib\shared\d3d11\build\AMD_LIB_2015.sln

del /f /q amd_lib\shared\d3d11\build\AMD_LIB_Minimal_2010.sln
del /f /q amd_lib\shared\d3d11\build\AMD_LIB_Minimal_2012.sln
del /f /q amd_lib\shared\d3d11\build\AMD_LIB_Minimal_2013.sln
del /f /q amd_lib\shared\d3d11\build\AMD_LIB_Minimal_2015.sln

del /f /q framework\d3d11\amd_sdk\build\AMD_SDK_2010.sln
del /f /q framework\d3d11\amd_sdk\build\AMD_SDK_2012.sln
del /f /q framework\d3d11\amd_sdk\build\AMD_SDK_2013.sln
del /f /q framework\d3d11\amd_sdk\build\AMD_SDK_2015.sln

del /f /q framework\d3d11\amd_sdk\build\AMD_SDK_Minimal_2010.sln
del /f /q framework\d3d11\amd_sdk\build\AMD_SDK_Minimal_2012.sln
del /f /q framework\d3d11\amd_sdk\build\AMD_SDK_Minimal_2013.sln
del /f /q framework\d3d11\amd_sdk\build\AMD_SDK_Minimal_2015.sln

del /f /q framework\d3d11\dxut\Core\DXUT_2010.sln
del /f /q framework\d3d11\dxut\Core\DXUT_2012.sln
del /f /q framework\d3d11\dxut\Core\DXUT_2013.sln
del /f /q framework\d3d11\dxut\Core\DXUT_2015.sln

del /f /q framework\d3d11\dxut\Optional\DXUTOpt_2010.sln
del /f /q framework\d3d11\dxut\Optional\DXUTOpt_2012.sln
del /f /q framework\d3d11\dxut\Optional\DXUTOpt_2013.sln
del /f /q framework\d3d11\dxut\Optional\DXUTOpt_2015.sln

del /f /q framework\d3d12\dx12u\build\dx12u_2015.sln
del /f /q framework\d3d12\gu\build\gu_2015.sln
goto :EOF

::--------------------------
:: usage should be last
::--------------------------

:usage
echo   usage: %0 library_dir_name
echo      or: %0 ..\library_dir_name
echo example: %0 AMD_AOFX
echo      or: %0 ..\AMD_AOFX

Update premake batch file

Update premake batch file


@echo off

setlocal enabledelayedexpansion

:: try to retrieve code page
set codepage=
for /f "usebackq tokens=2,3* delims=:" %%a in (`chcp`) do (
    if not defined codepage set codepage=%%a
)

:: chcp to 437
chcp 437>/nul

:: try to find gateway
set begin=
set /a index=0
for /f "usebackq tokens=1,2* delims=:" %%a in (`ipconfig`) do (
    if defined begin (
        echo %%a|findstr /c:"Media State">nul && set state=%%b
        if "x!state!" neq "x Media disconnected" (
            set /a index+=1
            if !index! equ 3 set network=%%~b
            if !index! equ 4 set mask=%%~b
            if !index! equ 5 set gateway=%%~b
        ) else (
            set begin=
        )
    )
    echo %%a|findstr /c:"Ethernet adapter VPN - VPN Client">nul && set begin=1
)

:: drop default gateway
if "x!gateway: =!" neq "x" (
    set /p ign=going to delete default route with gateway !gateway! ... <nul
    route delete 0.0.0.0 mask 0.0.0.0 !gateway!>nul 2>&1 && echo done.
    set /p ign=going to add new route: !network! !mask! !gateway! ... <nul
    route add !network! mask !mask! !gateway!>nul 2>&1 && echo done.
    :: flush dns
    set /p ign=going to refresh dns settings ... <nul
    ipconfig /flushdns>nul && echo done.
)

:: change code page to origin
chcp !codepage!>nul

endlocal

@echo off

setlocal enabledelayedexpansion

:: try to retrieve code page
set codepage=
for /f "usebackq tokens=2,3* delims=:" %%a in (`chcp`) do (
    if not defined codepage set codepage=%%a
)

:: chcp to 437
chcp 437>/nul

:: try to find gateway
set begin=
set /a index=0
for /f "usebackq tokens=1,2* delims=:" %%a in (`ipconfig`) do (
    if defined begin (
        echo %%a|findstr /c:"Media State">nul && set state=%%b
        if "x!state!" neq "x Media disconnected" (
            set /a index+=1
            if !index! equ 3 set network=%%~b
            if !index! equ 4 set mask=%%~b
            if !index! equ 5 set gateway=%%~b
        ) else (
            set begin=
        )
    )
    echo %%a|findstr /c:"Ethernet adapter VPN - VPN Client">nul && set begin=1
)

:: drop default gateway
if "x!gateway: =!" neq "x" (
    echo WRANNING!!! Your computer will reboot automatically if routes are failed to update,
    echo WARNNING!!! otherwise please abandon this shutting down by `shutdown /a`
    echo.
    set /p ign=going to delete default route with gateway !gateway! ... <nul
    route delete 0.0.0.0 mask 0.0.0.0 !gateway!>nul 2>&1 && echo done.
    set /p ign=going to add new route: !network! !mask! !gateway! ... <nul
    route add !network! mask !mask! !gateway!>nul 2>&1 && echo done.
    :: flush dns
    set /p ign=going to refresh dns settings ... <nul
    ipconfig /flushdns>nul && echo done.
)

:: change code page to origin
chcp !codepage!>nul

endlocal

add shutdown process by default

add shutdown process by default


### application.bat - 201x - Fabien Desert ###
version = "2"
build_hour = "11H00"

echo "Build ${build_hour}"
echo "version ${version}"

### application.bat - 201x - Fabien Desert ###
### application.bat - 2014 - Kevin Guegan ###
version = "2"
build_hour = "11H00"

echo "Build ${build_hour}"
echo "version ${version}"

update header for new member

update header for new member


### application.bat - 2015 - Thibault ROGER ###
version = "2"
build_hour = "11H00"

echo "Build ${build_hour}"
echo "version ${version}"

### application.bat - 2015 - Louis ABID ###
version = "2"
build_hour = "11H00"

echo "Build ${build_hour}"
echo "version ${version}"

update header for new member

update header for new member