@set dbcl_build_folder=%appveyor_build_folder%
@if not "%appveyor%" == "True" set dbcl_build_folder=%cd%

@set dbcl_artifacts_folder=%dbcl_build_folder%\reports
@if exist %dbcl_artifacts_folder%\. (del /Q %dbcl_artifacts_folder%\*) else (md %dbcl_artifacts_folder%)
@set dbcl_packages_folder=%dbcl_build_folder%\packages

@set dbcl_nunit_runner_console=%dbcl_packages_folder%\NUnit.Runners.Net4.2.6.4\tools\nunit-console-x86.exe
@set dbcl_nunit_runner_options=/nologo /noshadow /work:%dbcl_artifacts_folder%

@set dbcl_zip_console=%dbcl_packages_folder%\7-Zip.CommandLine.9.20.0\tools\7za.exe

@set dbcl_coveralls_console=%dbcl_packages_folder%\coveralls.io.1.3.4\tools\coveralls.net.exe
@set dbcl_coveralls_options=--opencover %dbcl_artifacts_folder%\OpenCover.*.xml --repo-token "%coveralls_repo_token%"

@set dbcl_report_generator_console=%dbcl_packages_folder%\ReportGenerator.2.3.5.0\tools\ReportGenerator.exe
@set dbcl_report_generator_options=-targetdir:%dbcl_artifacts_folder% -reports:%dbcl_artifacts_folder%\OpenCover.*.xml

@Rem OpenCover Debug Build
@set OpenCoverDebugBuild="E:\GitHub\opencover\main\bin\Debug\OpenCover.Console.exe"

@Rem OpenCover Release Build
@set OpenCoverReleaseBuild="E:\GitHub\opencover\main\bin\Release\OpenCover.Console.exe"

@Rem OpenCover MSI Installed
@set OpenCoverMsiInstalled="C:\Program Files (x86)\OpenCover\OpenCover.Console.exe"

@Rem OpenCover Nuget Package
@Rem set OpenCoverNugetPackage=".\packages\OpenCover.4.6.166\tools\OpenCover.Console.exe"
@set OpenCoverNugetPackage=".\packages\OpenCover.4.6.247-rc\tools\OpenCover.Console.exe"

@Rem OpenCover Command
@set OpenCoverCommand=%OpenCoverNugetPackage%

@Rem Local OpenCover Override
@if not "%appveyor%" == "True" set OpenCoverCommand=%OpenCoverReleaseBuild%

@Rem OpenCover Options
@set OpenCoverOptions=-register:user -threshold:1 -mergebyhash -hideskipped:All

@Rem OpenCover command
@set OpenCoverCommandAndOptions=%OpenCoverCommand% %OpenCoverOptions%

@echo AppVeyor env.variable: %appveyor%
@echo AppVeyor Build Folder: %appveyor_build_folder%
@echo Current        Folder: %cd%
@echo dbcl Artifacts Folder: %dbcl_artifacts_folder%
@echo dbcl     Build Folder: %dbcl_build_folder%
@echo NUnit         Options: %dbcl_nunit_runner_options%
@echo OpenCover     Command: %OpenCoverCommand%
@echo OpenCover     Options: %OpenCoverOptions%
@%OpenCoverCommand% -version
@rem if not "%appveyor%" == "True" pause
@echo.

@Rem Local Build?
@if not "%appveyor%" == "True" if exist "C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" ("C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" DBCL.sln)

@call :run-single-test "Extensions"  "+[DBCL]DD.Extends*"
@call :run-single-test "ICodeSet"    "+[DBCL]DD.Collections.ICodeSet* +[DBCL]DD.Text*"
@call :run-single-test "BitSetArray" "+[DBCL]DD.Collections.BitSetArray*"
@call :run-single-test "Diagnostics" "+[DBCL]DD.Diagnostics*"
@exit /b

:run-single-test
@echo assembly  name: %1
@echo filter applied: %2
@%OpenCoverCommandAndOptions% ^
-output:"%dbcl_artifacts_folder%\OpenCover.%1.xml" ^
-filter:%2 ^
-target:"%dbcl_nunit_runner_console%" ^
-targetdir:".\Source\Test\NUnit.%1\bin\Debug" ^
-targetargs:"NUnit.%1.dll /result:\"NUnit.%1.xml\" %dbcl_nunit_runner_options%"
@echo -------------------------------------
@echo.
@rem if not "%appveyor%" == "True" pause
@exit /b

@set dbcl_build_folder=%appveyor_build_folder%
@if not "%appveyor%" == "True" set dbcl_build_folder=%cd%

@set dbcl_artifacts_folder=%dbcl_build_folder%\reports
@if exist %dbcl_artifacts_folder%\. (del /Q %dbcl_artifacts_folder%\*) else (md %dbcl_artifacts_folder%)
@set dbcl_packages_folder=%dbcl_build_folder%\packages

@set dbcl_nunit_runner_console=%dbcl_packages_folder%\NUnit.Runners.Net4.2.6.4\tools\nunit-console-x86.exe
@set dbcl_nunit_runner_options=/nologo /noshadow /work:%dbcl_artifacts_folder%

@set dbcl_zip_console=%dbcl_packages_folder%\7-Zip.CommandLine.9.20.0\tools\7za.exe

@set dbcl_coveralls_console=%dbcl_packages_folder%\coveralls.io.1.3.4\tools\coveralls.net.exe
@set dbcl_coveralls_options=--opencover %dbcl_artifacts_folder%\OpenCover.*.xml --repo-token "%coveralls_repo_token%"

@set dbcl_report_generator_console=%dbcl_packages_folder%\ReportGenerator.2.3.5.0\tools\ReportGenerator.exe
@set dbcl_report_generator_options=-targetdir:%dbcl_artifacts_folder% -reports:%dbcl_artifacts_folder%\OpenCover.*.xml

@Rem OpenCover Debug Build
@set OpenCoverDebugBuild="E:\GitHub\opencover\main\bin\Debug\OpenCover.Console.exe"

@Rem OpenCover Release Build
@set OpenCoverReleaseBuild="E:\GitHub\opencover\main\bin\Release\OpenCover.Console.exe"

@Rem OpenCover MSI Installed
@set OpenCoverMsiInstalled="C:\Program Files (x86)\OpenCover\OpenCover.Console.exe"

@Rem OpenCover Nuget Package
@Rem set OpenCoverNugetPackage=".\packages\OpenCover.4.6.166\tools\OpenCover.Console.exe"
@set OpenCoverNugetPackage=".\packages\OpenCover.4.6.247-rc\tools\OpenCover.Console.exe"

@Rem OpenCover Command
@set OpenCoverCommand=%OpenCoverNugetPackage%

@Rem Local OpenCover Override
@if not "%appveyor%" == "True" set OpenCoverCommand=%OpenCoverReleaseBuild%

@Rem OpenCover Options
@set OpenCoverOptions=-register:user -threshold:1 -mergebyhash -hideskipped:All

@Rem OpenCover command
@set OpenCoverCommandAndOptions=%OpenCoverCommand% %OpenCoverOptions%

@echo AppVeyor env.variable: %appveyor%
@echo AppVeyor Build Folder: %appveyor_build_folder%
@echo Current        Folder: %cd%
@echo dbcl Artifacts Folder: %dbcl_artifacts_folder%
@echo dbcl     Build Folder: %dbcl_build_folder%
@echo NUnit         Options: %dbcl_nunit_runner_options%
@echo OpenCover     Command: %OpenCoverCommand%
@echo OpenCover     Options: %OpenCoverOptions%
@%OpenCoverCommand% -version
@rem if not "%appveyor%" == "True" pause
@echo.

@Rem Local Build?
@if not "%appveyor%" == "True" if exist "C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" ("C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" DBCL.sln)

@call :run-single-test "Extensions"  "+[DBCL]*"
@call :run-single-test "ICodeSet"    "+[DBCL]*"
@call :run-single-test "BitSetArray" "+[DBCL]*"
@call :run-single-test "Diagnostics" "+[DBCL]*"
@exit /b

:run-single-test
@echo assembly  name: %1
@echo filter applied: %2
@%OpenCoverCommandAndOptions% ^
-output:"%dbcl_artifacts_folder%\OpenCover.%1.xml" ^
-filter:%2 ^
-target:"%dbcl_nunit_runner_console%" ^
-targetdir:".\Source\Test\NUnit.%1\bin\Debug" ^
-targetargs:"NUnit.%1.dll /result:\"NUnit.%1.xml\" %dbcl_nunit_runner_options%"
@echo -------------------------------------
@echo.
@rem if not "%appveyor%" == "True" pause
@exit /b

Update filters for OpenCover-rc

Update filters for OpenCover-rc


:: https://github.com/yotamHak/Steam-Related/wiki/redeemSteamKey.bat

@echo off

:: Getting key from clipboard
@powershell -sta "add-type -as System.Windows.Forms; [windows.forms.clipboard]::GetText()" > key.txt
set /p $Key= < key.txt

echo %$Key% | findstr /r "[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]-[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]-[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]" > nul
if %errorlevel%==1 (
	echo Clipboard doesn't contain a Steam Key.
	pause
	exit
)

:: Set Discord hook to this variable
set "$DiscordWebHookUrl="

:: Set session id from steam to this variable
set "$sessionid="

set "$ContentType=Content-Type: application/x-www-form-urlencoded; charset=UTF-8"
set "$Accept=accept: application/json"
set "$Origin=Origin: https://store.steampowered.com"
set "Cache=Cache-Control: no-cache"
set "$ContentLength=Content-Length: 64"
set "$Url=https://store.steampowered.com/account/ajaxregisterkey/"

:: Activating on Steam
curl -X POST -b cookies.txt -H "%$Cache%" -H "%$ContentType%" -d "sessionid=%$sessionid%" -d "product_key=%$Key%" %$Url% > res.json

:: Cleaning up the response
@powershell -sta "(Get-Content -Path 'res.json').replace('`','') | Set-Content cleanResponse.json;"
@powershell -sta "(Get-Content -Path 'cleanResponse.json').replace('""','') | Set-Content cleanResponse.json;"
:: Getting app name
@powershell -sta "select-string -Path 'cleanResponse.json' -Pattern 'line_item_description:([^}]+)' -AllMatches | foreach-object { $_.Matches } | foreach-object { $_.Value }" > appname.txt
@powershell -sta "(Get-Content -Path 'appname.txt').replace('line_item_description:','') | Set-Content appname.txt;"
:: Getting app id
@powershell -sta "select-string -Path 'cleanResponse.json' -Pattern '{packageid:([^,]+)' -AllMatches | foreach-object { $_.Matches } | foreach-object { $_.Value }" > appid.txt
@powershell -sta "(Get-Content -Path 'appid.txt').replace('{packageid:','') | Set-Content appid.txt;"

:: Saving into Variables
set /p $cleanResponse= < cleanResponse.json
set /p $appName= < appname.txt
set /p $appId= < appid.txt
set "appSubUrl=\"url\":\"https://store.steampowered.com/sub/%$appId%/\""

:: Checking activation response
type "cleanResponse.json" | find "purchase_result_details:0" > nul
if %errorlevel%==0 (
	set "color=\"color\":65280"
	set "title=\"title\":\"Activated\""
	set "description=\"description\":\"Key activated successfuly!\""
	set "result=%$appName% - %$Key%: Key activated successfuly!"
)
type "cleanResponse.json" | find "purchase_result_details:9" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Already Owns\""
	set "description=\"description\":\"This Steam account already owns the product contained in this offer. To access them, visit your library in the Steam client.\""
	set "result=%$appName% - %$Key%: Already Owns"
)
type "cleanResponse.json" | find "purchase_result_details:13" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Unavailable\""
	set "description=\"description\":\"Sorry, but this product is not available for purchase in this country. Your product key has not been redeemed.\""
	set "result=%$appName% - %$Key%: Unavailable"
)
type "cleanResponse.json" | find "purchase_result_details:14" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Invalid\""
	set "description=\"description\":\"The product code you have entered is not valid. Please double check to see if you have mistyped your key. I, L, and 1 can look alike, as can V and Y, and 0 and O.\""
	set "result=%$appName% - %$Key%: Invalid"
)
type "cleanResponse.json" | find "purchase_result_details:15" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Duplicate\""
	set "description=\"description\":\"The product code you have entered has already been activated by a different Steam account. This code cannot be used again. Please contact the retailer or online seller where the code was purchased for assistance.\""
	set "result=%$appName% - %$Key%: Duplicate"
)
type "cleanResponse.json" | find "purchase_result_details:24" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Missing Base Game\""
	set "description=\"description\":\"The product code you have entered requires ownership of another product before activation. If you are trying to activate an expansion pack or downloadable content, please first activate the original game, then activate this additional content.\""
	set "result=%$appName% - %$Key%: Missing Base Game"
)
type "cleanResponse.json" | find "purchase_result_details:50" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Wallet Code\""
	set "description=\"description\":\"The code you have entered is from a Steam Gift Card or Steam Wallet Code.\""
	set "result=%$appName% - %$Key%: Wallet Code"
)
type "cleanResponse.json" | find "purchase_result_details:53" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Too Many Activations\""
	set "description=\"description\":\"There have been too many recent activation attempts from this account or Internet address. Please wait and try your product code again later.\""
	set "result=%$appName% - %$Key%: Too Many Activations"
)

cls

:: Sending result to Discord
curl -H "Content-Type: application/json" -X POST -d "{ \"username\": \"%$appName%: %$Key%\",\"content\": \"%$cleanResponse%\", \"embeds\":[{%appSubUrl%,%title%,%description%,%color%,\"author\": {\"name\": \"%$appName%: %$Key%\"}}]}" %$DiscordWebHookUrl%

:: Cleaning up files
del res.json
del cleanResponse.json
del key.txt
del appname.txt
del appid.txt

echo %result%
pause
exit

:: https://github.com/yotamHak/Steam-Related/wiki/redeemSteamKey.bat

@echo off

:: Getting key from clipboard
@powershell -sta "add-type -as System.Windows.Forms; [windows.forms.clipboard]::GetText()" > key.txt
set /p $Key= < key.txt

echo %$Key% | findstr /r "[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]-[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]-[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]" > nul
if %errorlevel%==1 (
	echo Clipboard doesn't contain a Steam Key.
	pause
	exit
)

:: Set Discord hook to this variable
set "$DiscordWebHookUrl="

:: Set session id from steam to this variable
set "$sessionid="

set "$ContentType=Content-Type: application/x-www-form-urlencoded; charset=UTF-8"
set "Cache=Cache-Control: no-cache"
set "$Url=https://store.steampowered.com/account/ajaxregisterkey/"

:: Activating on Steam
curl -X POST -b cookies.txt -H "%$Cache%" -H "%$ContentType%" -d "sessionid=%$sessionid%" -d "product_key=%$Key%" %$Url% > res.json

:: Cleaning up the response
@powershell -sta "(Get-Content -Path 'res.json').replace('`','') | Set-Content cleanResponse.json;"
@powershell -sta "(Get-Content -Path 'cleanResponse.json').replace('""','') | Set-Content cleanResponse.json;"
:: Getting app name
@powershell -sta "select-string -Path 'cleanResponse.json' -Pattern 'line_item_description:([^}]+)' -AllMatches | foreach-object { $_.Matches } | foreach-object { $_.Value }" > appname.txt
@powershell -sta "(Get-Content -Path 'appname.txt').replace('line_item_description:','') | Set-Content appname.txt;"
:: Getting app id
@powershell -sta "select-string -Path 'cleanResponse.json' -Pattern '{packageid:([^,]+)' -AllMatches | foreach-object { $_.Matches } | foreach-object { $_.Value }" > appid.txt
@powershell -sta "(Get-Content -Path 'appid.txt').replace('{packageid:','') | Set-Content appid.txt;"

:: Saving into Variables
set /p $cleanResponse= < cleanResponse.json
set /p $appName= < appname.txt
set /p $appId= < appid.txt
set "appSubUrl=\"url\":\"https://store.steampowered.com/sub/%$appId%/\""

:: Checking activation response
type "cleanResponse.json" | find "purchase_result_details:0" > nul
if %errorlevel%==0 (
	set "color=\"color\":65280"
	set "title=\"title\":\"Activated\""
	set "description=\"description\":\"Key activated successfuly!\""
	set "result=%$appName% - %$Key%: Key activated successfuly!"
)
type "cleanResponse.json" | find "purchase_result_details:9" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Already Owns\""
	set "description=\"description\":\"This Steam account already owns the product contained in this offer. To access them, visit your library in the Steam client.\""
	set "result=%$appName% - %$Key%: Already Owns"
)
type "cleanResponse.json" | find "purchase_result_details:13" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Unavailable\""
	set "description=\"description\":\"Sorry, but this product is not available for purchase in this country. Your product key has not been redeemed.\""
	set "result=%$appName% - %$Key%: Unavailable"
)
type "cleanResponse.json" | find "purchase_result_details:14" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Invalid\""
	set "description=\"description\":\"The product code you have entered is not valid. Please double check to see if you have mistyped your key. I, L, and 1 can look alike, as can V and Y, and 0 and O.\""
	set "result=%$appName% - %$Key%: Invalid"
)
type "cleanResponse.json" | find "purchase_result_details:15" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Duplicate\""
	set "description=\"description\":\"The product code you have entered has already been activated by a different Steam account. This code cannot be used again. Please contact the retailer or online seller where the code was purchased for assistance.\""
	set "result=%$appName% - %$Key%: Duplicate"
)
type "cleanResponse.json" | find "purchase_result_details:24" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Missing Base Game\""
	set "description=\"description\":\"The product code you have entered requires ownership of another product before activation. If you are trying to activate an expansion pack or downloadable content, please first activate the original game, then activate this additional content.\""
	set "result=%$appName% - %$Key%: Missing Base Game"
)
type "cleanResponse.json" | find "purchase_result_details:50" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Wallet Code\""
	set "description=\"description\":\"The code you have entered is from a Steam Gift Card or Steam Wallet Code.\""
	set "result=%$appName% - %$Key%: Wallet Code"
)
type "cleanResponse.json" | find "purchase_result_details:53" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Too Many Activations\""
	set "description=\"description\":\"There have been too many recent activation attempts from this account or Internet address. Please wait and try your product code again later.\""
	set "result=%$appName% - %$Key%: Too Many Activations"
)

cls

:: Sending result to Discord
curl -H "Content-Type: application/json" -X POST -d "{ \"username\": \"%$appName%: %$Key%\",\"content\": \"%$cleanResponse%\", \"embeds\":[{%appSubUrl%,%title%,%description%,%color%,\"author\": {\"name\": \"%$appName%: %$Key%\"}}]}" %$DiscordWebHookUrl%

:: Cleaning up files
del res.json
del cleanResponse.json
del key.txt
del appname.txt
del appid.txt

echo %result%
pause
exit

Update redeemSteamKey.bat

Update redeemSteamKey.bat

Little cleanup of unneeded vars


@echo off

@powershell -sta "add-type -as System.Windows.Forms; [windows.forms.clipboard]::GetText()" > key.txt
set /p $Key= < key.txt

echo %$Key% | findstr /r "[a-zA-z0-9][a-zA-z0-9][a-zA-z0-9][a-zA-z0-9][a-zA-z0-9]-[a-zA-z0-9][a-zA-z0-9][a-zA-z0-9][a-zA-z0-9][a-zA-z0-9]-[a-zA-z0-9][a-zA-z0-9][a-zA-z0-9][a-zA-z0-9][a-zA-z0-9]" > nul
if %errorlevel%==1 (
	echo Clipboard doesn't contain a Steam Key.
	Pause
	exit
)

set "$ContentType=Content-Type: application/x-www-form-urlencoded; charset=UTF-8"
set "$Accept=accept: application/json"
set "$Origin=Origin: https://store.steampowered.com"
set "$DNT=DNT: 1"
set "Cache=Cache-Control: no-cache"
set "$ContentLength=Content-Length: 64"
set "$Url=https://store.steampowered.com/account/ajaxregisterkey/"
set "$sessionid=859e41f7f39da804c05088ba"
set "$DiscordWebHookUrl=" ::Fill with Discord webhook

:: Activating on Steam
curl -X POST -b cookies.txt -H "%$Cache%" -H "%$DNT%" -H "%$ContentType%" -d "sessionid=%$sessionid%" -d "product_key=%$Key%" %$Url% > res.json

:: Cleaning up the response
@powershell -sta "(Get-Content -Path 'res.json').replace('`','') | Set-Content cleanResponse.json;"
@powershell -sta "(Get-Content -Path 'cleanResponse.json').replace('""','') | Set-Content cleanResponse.json;"

:: Saving into Variables
set /p $cleanResponse= < cleanResponse.json

:: Checking activation response
type "cleanResponse.json" | find "purchase_result_details:0" > nul
if %errorlevel%==0 (
	set "color=\"color\":65280"
	set "title=\"title\":\"Activated\""
	set "description=\"description\":\"Key activated successfuly!\""
	set "result=%$Key%: Key activated successfuly!"
)
type "cleanResponse.json" | find "purchase_result_details:9" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Already Owns\""
	set "description=\"description\":\"This Steam account already owns the product contained in this offer. To access them, visit your library in the Steam client.\""
	set "result=%$Key%: Already Owns"
)
type "cleanResponse.json" | find "purchase_result_details:13" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Unavailable\""
	set "description=\"description\":\"Sorry, but this product is not available for purchase in this country. Your product key has not been redeemed.\""
	set "result=%$Key%: Unavailable"
)
type "cleanResponse.json" | find "purchase_result_details:14" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Invalid\""
	set "description=\"description\":\"The product code you have entered is not valid. Please double check to see if you have mistyped your key. I, L, and 1 can look alike, as can V and Y, and 0 and O.\""
	set "result=%$Key%: Invalid"
)
type "cleanResponse.json" | find "purchase_result_details:15" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Duplicate\""
	set "description=\"description\":\"The product code you have entered has already been activated by a different Steam account. This code cannot be used again. Please contact the retailer or online seller where the code was purchased for assistance.\""
	set "result=%$Key%: Duplicate"
)
type "cleanResponse.json" | find "purchase_result_details:24" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Missing Base Game\""
	set "description=\"description\":\"The product code you have entered requires ownership of another product before activation. If you are trying to activate an expansion pack or downloadable content, please first activate the original game, then activate this additional content.\""
	set "result=%$Key%: Missing Base Game"
)
type "cleanResponse.json" | find "purchase_result_details:50" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Wallet Code\""
	set "description=\"description\":\"The code you have entered is from a Steam Gift Card or Steam Wallet Code.\""
	set "result=%$Key%: Wallet Code"
)
type "cleanResponse.json" | find "purchase_result_details:53" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Too Many Activations\""
	set "description=\"description\":\"There have been too many recent activation attempts from this account or Internet address. Please wait and try your product code again later.\""
	set "result=%$Key%: Too Many Activations"
)

cls

:: Sending result to Discord
curl -H "Content-Type: application/json" -X POST -d "{ \"content\": \"%$cleanResponse%\", \"embeds\":[{%title%,%description%,%color%,\"author\": {\"name\": \"%$Key%\"}}]}" %$DiscordWebHookUrl%

:: Cleaning up files
del res.json
del cleanResponse.json
del key.txt

ECHO %result%
PAUSE
EXIT

:: https://github.com/yotamHak/Steam-Related/wiki/redeemSteamKey.bat

@echo off

:: Getting key from clipboard
@powershell -sta "add-type -as System.Windows.Forms; [windows.forms.clipboard]::GetText()" > key.txt
set /p $Key= < key.txt

echo %$Key% | findstr /r "[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]-[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]-[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]" > nul
if %errorlevel%==1 (
	echo Clipboard doesn't contain a Steam Key.
	pause
	exit
)

:: Set Discord hook to this variable
set "$DiscordWebHookUrl="

:: Set session id from steam to this variable
set "$sessionid="

set "$ContentType=Content-Type: application/x-www-form-urlencoded; charset=UTF-8"
set "$Accept=accept: application/json"
set "$Origin=Origin: https://store.steampowered.com"
set "Cache=Cache-Control: no-cache"
set "$ContentLength=Content-Length: 64"
set "$Url=https://store.steampowered.com/account/ajaxregisterkey/"

:: Activating on Steam
curl -X POST -b cookies.txt -H "%$Cache%" -H "%$ContentType%" -d "sessionid=%$sessionid%" -d "product_key=%$Key%" %$Url% > res.json

:: Cleaning up the response
@powershell -sta "(Get-Content -Path 'res.json').replace('`','') | Set-Content cleanResponse.json;"
@powershell -sta "(Get-Content -Path 'cleanResponse.json').replace('""','') | Set-Content cleanResponse.json;"
:: Getting app name
@powershell -sta "select-string -Path 'cleanResponse.json' -Pattern 'line_item_description:([^}]+)' -AllMatches | foreach-object { $_.Matches } | foreach-object { $_.Value }" > appname.txt
@powershell -sta "(Get-Content -Path 'appname.txt').replace('line_item_description:','') | Set-Content appname.txt;"
:: Getting app id
@powershell -sta "select-string -Path 'cleanResponse.json' -Pattern '{packageid:([^,]+)' -AllMatches | foreach-object { $_.Matches } | foreach-object { $_.Value }" > appid.txt
@powershell -sta "(Get-Content -Path 'appid.txt').replace('{packageid:','') | Set-Content appid.txt;"

:: Saving into Variables
set /p $cleanResponse= < cleanResponse.json
set /p $appName= < appname.txt
set /p $appId= < appid.txt
set "appSubUrl=\"url\":\"https://store.steampowered.com/sub/%$appId%/\""

:: Checking activation response
type "cleanResponse.json" | find "purchase_result_details:0" > nul
if %errorlevel%==0 (
	set "color=\"color\":65280"
	set "title=\"title\":\"Activated\""
	set "description=\"description\":\"Key activated successfuly!\""
	set "result=%$appName% - %$Key%: Key activated successfuly!"
)
type "cleanResponse.json" | find "purchase_result_details:9" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Already Owns\""
	set "description=\"description\":\"This Steam account already owns the product contained in this offer. To access them, visit your library in the Steam client.\""
	set "result=%$appName% - %$Key%: Already Owns"
)
type "cleanResponse.json" | find "purchase_result_details:13" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Unavailable\""
	set "description=\"description\":\"Sorry, but this product is not available for purchase in this country. Your product key has not been redeemed.\""
	set "result=%$appName% - %$Key%: Unavailable"
)
type "cleanResponse.json" | find "purchase_result_details:14" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Invalid\""
	set "description=\"description\":\"The product code you have entered is not valid. Please double check to see if you have mistyped your key. I, L, and 1 can look alike, as can V and Y, and 0 and O.\""
	set "result=%$appName% - %$Key%: Invalid"
)
type "cleanResponse.json" | find "purchase_result_details:15" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Duplicate\""
	set "description=\"description\":\"The product code you have entered has already been activated by a different Steam account. This code cannot be used again. Please contact the retailer or online seller where the code was purchased for assistance.\""
	set "result=%$appName% - %$Key%: Duplicate"
)
type "cleanResponse.json" | find "purchase_result_details:24" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Missing Base Game\""
	set "description=\"description\":\"The product code you have entered requires ownership of another product before activation. If you are trying to activate an expansion pack or downloadable content, please first activate the original game, then activate this additional content.\""
	set "result=%$appName% - %$Key%: Missing Base Game"
)
type "cleanResponse.json" | find "purchase_result_details:50" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Wallet Code\""
	set "description=\"description\":\"The code you have entered is from a Steam Gift Card or Steam Wallet Code.\""
	set "result=%$appName% - %$Key%: Wallet Code"
)
type "cleanResponse.json" | find "purchase_result_details:53" > nul
if %errorlevel%==0 (
	set "color=\"color\":12845619"
	set "title=\"title\":\"Fail - Too Many Activations\""
	set "description=\"description\":\"There have been too many recent activation attempts from this account or Internet address. Please wait and try your product code again later.\""
	set "result=%$appName% - %$Key%: Too Many Activations"
)

cls

:: Sending result to Discord
curl -H "Content-Type: application/json" -X POST -d "{ \"username\": \"%$appName%: %$Key%\",\"content\": \"%$cleanResponse%\", \"embeds\":[{%appSubUrl%,%title%,%description%,%color%,\"author\": {\"name\": \"%$appName%: %$Key%\"}}]}" %$DiscordWebHookUrl%

:: Cleaning up files
del res.json
del cleanResponse.json
del key.txt
del appname.txt
del appid.txt

echo %result%
pause
exit

Update redeemSteamKey.bat

Update redeemSteamKey.bat

Regex fix and better notifications to discord


:: Batch Script to Detect Google Chrome or Mozilla Firefox installation on machine
:: Execute detected browser or default browser if no browser detected

:: Author: Adnan Umer <u.adnan@outlook.com>
:: Dated: 24 Janvary, 2015

@echo off
setlocal EnableDelayedExpansion

echo Detecting 32-bit Installed Browsers
for /f "tokens=2,*" %%A in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Clients\StartMenuInternet" /ve 2^>nul') do set "Default=%%B"
for /f "skip=3 delims=" %%A in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Clients\StartMenuInternet" 2^>nul') do (
    if "%%~nxA"=="Google Chrome" (
    	set "CHROMEPATH=%%~A"
    	goto exec
    ) else (
    	if "%%~nxA"=="Mozilla Firefox" (
    		set "CHROMEPATH=%%~A"
    		goto exec
    	)
    )
)

echo Detecting 64-bit Installed Browsers
for /f "tokens=2,*" %%A in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet" /ve 2^>nul') do set "Default=%%B"
for /f "skip=3 delims=" %%A in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet" 2^>nul') do (
    if "%%~nxA"=="Google Chrome" (
    	set "CHROMEPATH=%%~A"
    	goto exec
    ) else (
    	if "%%~nxA"=="Mozilla Firefox" (
    		set "CHROMEPATH=%%~A"
    		goto exec
    	)
    )
)
goto notfound

:exec
echo Successfully Found Compatible Web browser
for /f "tokens=2,*" %%A in ('reg query "%CHROMEPATH%\shell\open\command" /ve 2^>nul') do set "Command=%%~B"
start "Browser" "%Command%" %1 %2 %3 %4 %5 %6 %7 %8 %9

goto end

:notfound
echo Failed to find any Compatible Web Browser
echo Starting Default Webbrowser
start "HTML" %1 %2 %3 %4 %5 %6 %7 %8 %9

:end
endlocal

:: Batch Script to Detect Google Chrome or Mozilla Firefox installation on machine
:: Execute detected browser or default browser if no browser detected

:: Copyright (c) Adnan Umer <u.adnan@outlook.com>.
:: All rights reserved. Follow me @MrAdnanUmer

:: Permission is hereby granted, free of charge, to any person obtaining a copy of this
:: software and associated documentation files (the "Software"), to deal in the Software
:: without restriction, including without limitation the rights to use, copy, modify, merge,
:: publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
:: to whom the Software is furnished to do so, subject to the following conditions:
::
:: The above copyright notice and this permission notice shall be included in all copies or
:: substantial portions of the Software.
::
:: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
:: INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
:: PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
:: FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
:: OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
:: DEALINGS IN THE SOFTWARE.

@echo off
setlocal EnableDelayedExpansion

echo Detecting 32-bit Installed Browsers
for /f "tokens=2,*" %%A in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Clients\StartMenuInternet" /ve 2^>nul') do set "Default=%%B"
for /f "skip=3 delims=" %%A in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Clients\StartMenuInternet" 2^>nul') do (
    if "%%~nxA"=="Google Chrome" (
    	set "CHROMEPATH=%%~A"
    	goto exec
    ) else (
    	if "%%~nxA"=="Mozilla Firefox" (
    		set "CHROMEPATH=%%~A"
    		goto exec
    	)
    )
)

echo Detecting 64-bit Installed Browsers
for /f "tokens=2,*" %%A in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet" /ve 2^>nul') do set "Default=%%B"
for /f "skip=3 delims=" %%A in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet" 2^>nul') do (
    if "%%~nxA"=="Google Chrome" (
    	set "CHROMEPATH=%%~A"
    	goto exec
    ) else (
    	if "%%~nxA"=="Mozilla Firefox" (
    		set "CHROMEPATH=%%~A"
    		goto exec
    	)
    )
)
goto notfound

:exec
echo Successfully Found Compatible Web browser
for /f "tokens=2,*" %%A in ('reg query "%CHROMEPATH%\shell\open\command" /ve 2^>nul') do set "Command=%%~B"
start "Browser" "%Command%" %1 %2 %3 %4 %5 %6 %7 %8 %9

goto end

:notfound
echo Failed to find any Compatible Web Browser
echo Starting Default Webbrowser
start "HTML" %1 %2 %3 %4 %5 %6 %7 %8 %9

:end
endlocal

Update RunBrowser.bat

Update RunBrowser.bat


update a batch to run testem.

update a batch to run testem.


@echo off

:: Init Script for cmd.exe
:: Created as part of cmder project

:: !!! THIS FILE IS OVERWRITTEN WHEN CMDER IS UPDATED
:: !!! Use "%CMDER_ROOT%\config\user-profile.cmd" to add your own startup commands

:: Use /v command line arg or set to > 0 for verbose output to aid in debugging.
set verbose-output=0
set debug-output=0
set max_depth=1

:: Find root dir
if not defined CMDER_ROOT (
    if defined ConEmuDir (
        for /f "delims=" %%i in ("%ConEmuDir%\..\..") do (
            set "CMDER_ROOT=%%~fi"
        )
    ) else (
        for /f "delims=" %%i in ("%~dp0\..") do (
            set "CMDER_ROOT=%%~fi"
        )
    )
)

:: Remove trailing '\' from %CMDER_ROOT%
if "%CMDER_ROOT:~-1%" == "\" SET "CMDER_ROOT=%CMDER_ROOT:~0,-1%"

call "%cmder_root%\vendor\lib\lib_base"
call "%cmder_root%\vendor\lib\lib_path"
call "%cmder_root%\vendor\lib\lib_console"
call "%cmder_root%\vendor\lib\lib_git"
call "%cmder_root%\vendor\lib\lib_profile"

:var_loop
    if "%~1" == "" (
        goto :start
    ) else if /i "%1"=="/v" (
        set verbose-output=1
    ) else if /i "%1"=="/d" (
        set debug-output=1
    ) else if /i "%1" == "/max_depth" (
        if "%~2" geq "1" if "%~2" leq "5" (
            set "max_depth=%~2"
            shift
        ) else (
            %lib_console% show_error "'/max_depth' requires a number between 1 and 5!"
            exit /b
        )
    ) else if /i "%1" == "/c" (
        if exist "%~2" (
            if not exist "%~2\bin" mkdir "%~2\bin"
            set "cmder_user_bin=%~2\bin"
            if not exist "%~2\config\profile.d" mkdir "%~2\config\profile.d"
            set "cmder_user_config=%~2\config"
            shift
        )
    ) else if /i "%1" == "/user_aliases" (
        if exist "%~2" (
            set "user-aliases=%~2"
            shift
        )
    ) else if /i "%1" == "/git_install_root" (
        if exist "%~2" (
            set "GIT_INSTALL_ROOT=%~2"
            shift
        ) else (
            %lib_console% show_error "The Git install root folder "%~2", you specified does not exist!"
            exit /b
        )
    ) else if /i "%1" == "/home" (
        if exist "%~2" (
            set "HOME=%~2"
            shift
        ) else (
            %lib_console% show_error The home folder "%2", you specified does not exist!
            exit /b
        )
    ) else if /i "%1" == "/svn_ssh" (
        set SVN_SSH=%2
        shift
    )
    shift
goto var_loop

:start
%lib_console% debug-output init.bat "Env Var - CMDER_ROOT=%CMDER_ROOT%"
%lib_console% debug-output init.bat "Env Var - debug-output=%debug-output%"

if defined CMDER_USER_CONFIG (
    %lib_console% debug-output init.bat "CMDER IS ALSO USING INDIVIDUAL USER CONFIG FROM '%CMDER_USER_CONFIG%'!"
)

:: Pick right version of clink
if "%PROCESSOR_ARCHITECTURE%"=="x86" (
    set architecture=86
    set architecture_bits=32
) else (
    set architecture=64
    set architecture_bits=64
)

:: Tell the user about the clink config files...
if defined "%CMDER_USER_CONFIG%\settings" if not exist "%CMDER_USER_CONFIG%\settings" (
    echo Generating clink initial settings in "%CMDER_USER_CONFIG%\settings"
    echo Additional *.lua files in "%CMDER_USER_CONFIG%" are loaded on startup.\

} else if not exist "%CMDER_ROOT%\config\settings" (
    echo Generating clink initial settings in "%CMDER_ROOT%\config\settings"
    echo Additional *.lua files in "%CMDER_ROOT%\config" are loaded on startup.
)

:: Run clink
if defined CMDER_USER_CONFIG (
    "%CMDER_ROOT%\vendor\clink\clink_x%architecture%.exe" inject --quiet --profile "%CMDER_USER_CONFIG%" --scripts "%CMDER_ROOT%\vendor"
) else (
    "%CMDER_ROOT%\vendor\clink\clink_x%architecture%.exe" inject --quiet --profile "%CMDER_ROOT%\config" --scripts "%CMDER_ROOT%\vendor"
)

:: Prepare for git-for-windows

:: I do not even know, copypasted from their .bat
set PLINK_PROTOCOL=ssh
if not defined TERM set TERM=cygwin

:: The idea:
:: * if the users points as to a specific git, use that
:: * test if a git is in path and if yes, use that
:: * last, use our vendored git
:: also check that we have a recent enough version of git by examining the version string
setlocal enabledelayedexpansion
if defined GIT_INSTALL_ROOT (
    if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" goto :FOUND_GIT)
)

%lib_console% debug-output init.bat "Looking for Git install root..."

:: get the version information for vendored git binary
%lib_git% read_version VENDORED "%CMDER_ROOT%\vendor\git-for-windows\cmd"
%lib_git% validate_version VENDORED !GIT_VERSION_VENDORED!

:: check if git is in path...
for /F "delims=" %%F in ('where git.exe 2^>nul') do (
    :: get the absolute path to the user provided git binary
    pushd %%~dpF
    set "test_dir=!CD!"
    popd

    :: get the version information for the user provided git binary
    %lib_git% read_version USER "!test_dir!"
    %lib_git% validate_version USER !GIT_VERSION_USER!

    if !errorlevel! geq 0 (
        :: compare the user git version against the vendored version
        %lib_git% compare_versions USER VENDORED

        :: use the user provided git if its version is greater than, or equal to the vendored git
        if !errorlevel! geq 0 if exist "!test_dir:~0,-4!\cmd\git.exe" (
            set "GIT_INSTALL_ROOT=!test_dir:~0,-4!"
            set test_dir=
            goto :FOUND_GIT
        ) else if !errorlevel! geq 0 (
            set "GIT_INSTALL_ROOT=!test_dir!"
            set test_dir=
            goto :FOUND_GIT
        ) else (
            call :verbose-output Found old !GIT_VERSION_USER! in "!test_dir!", but not using...
            set test_dir=
        )
    ) else (

        :: if the user provided git executable is not found
        if !errorlevel! equ -255 (
            call :verbose-output No git at "!git_executable!" found.
            set test_dir=
        )

    )

)

:: our last hope: our own git...
:VENDORED_GIT
if exist "%CMDER_ROOT%\vendor\git-for-windows" (
    set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\git-for-windows"
    %lib_path% enhance_path "!GIT_INSTALL_ROOT!\cmd"
) else (
    goto :NO_GIT
)

:FOUND_GIT
:: Add git to the path
if defined GIT_INSTALL_ROOT (
    rem add the unix commands at the end to not shadow windows commands like more
    if exist "!GIT_INSTALL_ROOT!\cmd\git.exe" %lib_path% enhance_path "!GIT_INSTALL_ROOT!\cmd" append
    if exist "!GIT_INSTALL_ROOT!\mingw32" (
        %lib_path% enhance_path "!GIT_INSTALL_ROOT!\mingw32" append
    ) else if exist "!GIT_INSTALL_ROOT!\mingw64" (
        %lib_path% enhance_path "!GIT_INSTALL_ROOT!\mingw64" append
    )
    %lib_path% enhance_path "!GIT_INSTALL_ROOT!\usr\bin" append

    :: define SVN_SSH so we can use git svn with ssh svn repositories
    if not defined SVN_SSH set "SVN_SSH=%GIT_INSTALL_ROOT:\=\\%\\bin\\ssh.exe"
)

endlocal & set "PATH=%PATH%" & set "SVN_SSH=%SVN_SSH%" & set "GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%"
%lib_console% debug-output init.bat "Env Var - GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%"
%lib_console% debug-output init.bat "Found Git in: '%GIT_INSTALL_ROOT%'"
goto :PATH_ENHANCE

:NO_GIT
:: Skip this if GIT WAS FOUND else we did 'endlocal' above!
endlocal

:PATH_ENHANCE
%lib_path% enhance_path_recursive "%CMDER_ROOT%\bin" %max_depth%
if defined CMDER_USER_BIN (
  %lib_path% enhance_path_recursive "%CMDER_USER_BIN%" %max_depth%
)
%lib_path% enhance_path "%CMDER_ROOT%" append

:: Drop *.bat and *.cmd files into "%CMDER_ROOT%\config\profile.d"
:: to run them at startup.
%lib_profile% run_profile_d "%CMDER_ROOT%\config\profile.d"
if defined CMDER_USER_CONFIG (
  %lib_profile% run_profile_d "%CMDER_USER_CONFIG%\profile.d"
)

:: Allows user to override default aliases store using profile.d
:: scripts run above by setting the 'aliases' env variable.
::
:: Note: If overriding default aliases store file the aliases
:: must also be self executing, see '.\user-aliases.cmd.example',
:: and be in profile.d folder.
if not defined user-aliases (
  if defined CMDER_USER_CONFIG (
     set "user-aliases=%CMDER_USER_CONFIG%\user-aliases.cmd"
  ) else (
     set "user-aliases=%CMDER_ROOT%\config\user-aliases.cmd"
  )
)

:: The aliases environment variable is used by alias.bat to id
:: the default file to store new aliases in.
if not defined aliases (
  set "aliases=%user-aliases%"
)

:: Make sure we have a self-extracting user-aliases.cmd file
setlocal enabledelayedexpansion
if not exist "%user-aliases%" (
    echo Creating initial user-aliases store in "%user-aliases%"...
    copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%user-aliases%"
) else (
    type "%user-aliases%" | findstr /i ";= Add aliases below here" >nul
    if "!errorlevel!" == "1" (
        echo Creating initial user-aliases store in "%user-aliases%"...
        if defined CMDER_USER_CONFIG (
            copy "%user-aliases%" "%user-aliases%.old_format"
            copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%user-aliases%"
        ) else (
            copy "%user-aliases%" "%user-aliases%.old_format"
            copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%user-aliases%"
        )
    )
)

:: Update old 'user-aliases' to new self executing 'user-aliases.cmd'
if exist "%CMDER_ROOT%\config\aliases" (
  echo Updating old "%CMDER_ROOT%\config\aliases" to new format...
  type "%CMDER_ROOT%\config\aliases" >> "%user-aliases%" && del "%CMDER_ROOT%\config\aliases"
) else if exist "%user-aliases%.old_format" (
  echo Updating old "%user-aliases%" to new format...
  type "%user-aliases%.old_format" >> "%user-aliases%" && del "%user-aliases%.old_format"
)
endlocal

:: Add aliases to the environment
call "%user-aliases%"

:: See vendor\git-for-windows\README.portable for why we do this
:: Basically we need to execute this post-install.bat because we are
:: manually extracting the archive rather than executing the 7z sfx
if exist "%GIT_INSTALL_ROOT%\post-install.bat" (
    %lib_console% verbose-output "Running Git for Windows one time Post Install...."
    pushd "%GIT_INSTALL_ROOT%\"
    "%GIT_INSTALL_ROOT%\git-bash.exe" --no-needs-console --hide --no-cd --command=post-install.bat
    popd
)

:: Set home path
if not defined HOME set "HOME=%USERPROFILE%"
%lib_console% debug-output init.bat "Env Var - HOME=%HOME%"

set "initialConfig=%CMDER_ROOT%\config\user-profile.cmd"
if exist "%CMDER_ROOT%\config\user-profile.cmd" (
    REM Create this file and place your own command in there
    call "%CMDER_ROOT%\config\user-profile.cmd"
)

if defined CMDER_USER_CONFIG (
  set "initialConfig=%CMDER_USER_CONFIG%\user-profile.cmd"
  if exist "%CMDER_USER_CONFIG%\user-profile.cmd" (
      REM Create this file and place your own command in there
      call "%CMDER_USER_CONFIG%\user-profile.cmd"
  )
)

if not exist "%initialConfig%" (
    echo Creating user startup file: "%initialConfig%"
    (
echo :: use this file to run your own startup commands
echo :: use  in front of the command to prevent printing the command
echo.
echo :: uncomment this to have the ssh agent load when cmder starts
echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-agent.cmd"
echo.
echo :: uncomment this next two lines to use pageant as the ssh authentication agent
echo :: SET SSH_AUTH_SOCK=/tmp/.ssh-pageant-auth-sock
echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-pageant.cmd"
echo.
echo :: you can add your plugins to the cmder path like so
echo :: set "PATH=%%CMDER_ROOT%%\vendor\whatever;%%PATH%%"
echo.
echo @echo off
) >"%initialConfig%"
)

set initialConfig=
exit /b

@echo off

:: Init Script for cmd.exe
:: Created as part of cmder project

:: !!! THIS FILE IS OVERWRITTEN WHEN CMDER IS UPDATED
:: !!! Use "%CMDER_ROOT%\config\user-profile.cmd" to add your own startup commands

:: Use /v command line arg or set to > 0 for verbose output to aid in debugging.
set verbose-output=0
set debug-output=0
set max_depth=1

:: Find root dir
if not defined CMDER_ROOT (
    if defined ConEmuDir (
        for /f "delims=" %%i in ("%ConEmuDir%\..\..") do (
            set "CMDER_ROOT=%%~fi"
        )
    ) else (
        for /f "delims=" %%i in ("%~dp0\..") do (
            set "CMDER_ROOT=%%~fi"
        )
    )
)

:: Remove trailing '\' from %CMDER_ROOT%
if "%CMDER_ROOT:~-1%" == "\" SET "CMDER_ROOT=%CMDER_ROOT:~0,-1%"

call "%cmder_root%\vendor\lib\lib_base"
call "%cmder_root%\vendor\lib\lib_path"
call "%cmder_root%\vendor\lib\lib_console"
call "%cmder_root%\vendor\lib\lib_git"
call "%cmder_root%\vendor\lib\lib_profile"

:var_loop
    if "%~1" == "" (
        goto :start
    ) else if /i "%1"=="/v" (
        set verbose-output=1
    ) else if /i "%1"=="/d" (
        set debug-output=1
    ) else if /i "%1" == "/max_depth" (
        if "%~2" geq "1" if "%~2" leq "5" (
            set "max_depth=%~2"
            shift
        ) else (
            %lib_console% show_error "'/max_depth' requires a number between 1 and 5!"
            exit /b
        )
    ) else if /i "%1" == "/c" (
        if exist "%~2" (
            if not exist "%~2\bin" mkdir "%~2\bin"
            set "cmder_user_bin=%~2\bin"
            if not exist "%~2\config\profile.d" mkdir "%~2\config\profile.d"
            set "cmder_user_config=%~2\config"
            shift
        )
    ) else if /i "%1" == "/user_aliases" (
        if exist "%~2" (
            set "user-aliases=%~2"
            shift
        )
    ) else if /i "%1" == "/git_install_root" (
        if exist "%~2" (
            set "GIT_INSTALL_ROOT=%~2"
            shift
        ) else (
            %lib_console% show_error "The Git install root folder "%~2", you specified does not exist!"
            exit /b
        )
    ) else if /i "%1" == "/home" (
        if exist "%~2" (
            set "HOME=%~2"
            shift
        ) else (
            %lib_console% show_error The home folder "%2", you specified does not exist!
            exit /b
        )
    ) else if /i "%1" == "/svn_ssh" (
        set SVN_SSH=%2
        shift
    )
    shift
goto var_loop

:start
%lib_console% debug-output init.bat "Env Var - CMDER_ROOT=%CMDER_ROOT%"
%lib_console% debug-output init.bat "Env Var - debug-output=%debug-output%"

if defined CMDER_USER_CONFIG (
    %lib_console% debug-output init.bat "CMDER IS ALSO USING INDIVIDUAL USER CONFIG FROM '%CMDER_USER_CONFIG%'!"
)

:: Pick right version of clink
if "%PROCESSOR_ARCHITECTURE%"=="x86" (
    set architecture=86
    set architecture_bits=32
) else (
    set architecture=64
    set architecture_bits=64
)

:: Tell the user about the clink config files...
if defined "%CMDER_USER_CONFIG%\settings" if not exist "%CMDER_USER_CONFIG%\settings" (
    echo Generating clink initial settings in "%CMDER_USER_CONFIG%\settings"
    echo Additional *.lua files in "%CMDER_USER_CONFIG%" are loaded on startup.\

} else if not exist "%CMDER_ROOT%\config\settings" (
    echo Generating clink initial settings in "%CMDER_ROOT%\config\settings"
    echo Additional *.lua files in "%CMDER_ROOT%\config" are loaded on startup.
)

:: Run clink
if defined CMDER_USER_CONFIG (
    "%CMDER_ROOT%\vendor\clink\clink_x%architecture%.exe" inject --quiet --profile "%CMDER_USER_CONFIG%" --scripts "%CMDER_ROOT%\vendor"
) else (
    "%CMDER_ROOT%\vendor\clink\clink_x%architecture%.exe" inject --quiet --profile "%CMDER_ROOT%\config" --scripts "%CMDER_ROOT%\vendor"
)

:: Prepare for git-for-windows

:: I do not even know, copypasted from their .bat
set PLINK_PROTOCOL=ssh
if not defined TERM set TERM=cygwin

:: The idea:
:: * if the users points as to a specific git, use that
:: * test if a git is in path and if yes, use that
:: * last, use our vendored git
:: also check that we have a recent enough version of git by examining the version string
setlocal enabledelayedexpansion
if defined GIT_INSTALL_ROOT (
    if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" goto :FOUND_GIT)
)

%lib_console% debug-output init.bat "Looking for Git install root..."

:: get the version information for vendored git binary
%lib_git% read_version VENDORED "%CMDER_ROOT%\vendor\git-for-windows\cmd"
%lib_git% validate_version VENDORED !GIT_VERSION_VENDORED!

:: check if git is in path...
for /F "delims=" %%F in ('where git.exe 2^>nul') do (
    :: get the absolute path to the user provided git binary
    pushd %%~dpF
    set "test_dir=!CD!"
    popd

    :: get the version information for the user provided git binary
    %lib_git% read_version USER "!test_dir!"
    %lib_git% validate_version USER !GIT_VERSION_USER!

    if !errorlevel! geq 0 (
        :: compare the user git version against the vendored version
        %lib_git% compare_versions USER VENDORED

        :: use the user provided git if its version is greater than, or equal to the vendored git
        if !errorlevel! geq 0 if exist "!test_dir:~0,-4!\cmd\git.exe" (
            set "GIT_INSTALL_ROOT=!test_dir:~0,-4!"
            set test_dir=
            goto :FOUND_GIT
        ) else if !errorlevel! geq 0 (
            set "GIT_INSTALL_ROOT=!test_dir!"
            set test_dir=
            goto :FOUND_GIT
        ) else (
            call :verbose-output Found old !GIT_VERSION_USER! in "!test_dir!", but not using...
            set test_dir=
        )
    ) else (

        :: if the user provided git executable is not found
        if !errorlevel! equ -255 (
            call :verbose-output No git at "!git_executable!" found.
            set test_dir=
        )

    )

)

:: our last hope: our own git...
:VENDORED_GIT
if exist "%CMDER_ROOT%\vendor\git-for-windows" (
    set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\git-for-windows"
    %lib_path% enhance_path "!GIT_INSTALL_ROOT!\cmd"
) else (
    goto :NO_GIT
)

:FOUND_GIT
:: Add git to the path
if defined GIT_INSTALL_ROOT (
    rem add the unix commands at the end to not shadow windows commands like more
    if exist "!GIT_INSTALL_ROOT!\cmd\git.exe" %lib_path% enhance_path "!GIT_INSTALL_ROOT!\cmd" append
    if exist "!GIT_INSTALL_ROOT!\mingw32" (
        %lib_path% enhance_path "!GIT_INSTALL_ROOT!\mingw32" append
    ) else if exist "!GIT_INSTALL_ROOT!\mingw64" (
        %lib_path% enhance_path "!GIT_INSTALL_ROOT!\mingw64" append
    )
    %lib_path% enhance_path "!GIT_INSTALL_ROOT!\usr\bin" append

    :: define SVN_SSH so we can use git svn with ssh svn repositories
    if not defined SVN_SSH set "SVN_SSH=%GIT_INSTALL_ROOT:\=\\%\\bin\\ssh.exe"
    for /F "delims=" %%F in ('env /usr/bin/locale -uU 2^>nul') do (
        set "LANG=%%F"
    )
)

endlocal & set "PATH=%PATH%" & set "LANG=%LANG%" & set "SVN_SSH=%SVN_SSH%" & set "GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%"
%lib_console% debug-output init.bat "Env Var - GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%"
%lib_console% debug-output init.bat "Found Git in: '%GIT_INSTALL_ROOT%'"
goto :PATH_ENHANCE

:NO_GIT
:: Skip this if GIT WAS FOUND else we did 'endlocal' above!
endlocal

:PATH_ENHANCE
%lib_path% enhance_path_recursive "%CMDER_ROOT%\bin" %max_depth%
if defined CMDER_USER_BIN (
  %lib_path% enhance_path_recursive "%CMDER_USER_BIN%" %max_depth%
)
%lib_path% enhance_path "%CMDER_ROOT%" append

:: Drop *.bat and *.cmd files into "%CMDER_ROOT%\config\profile.d"
:: to run them at startup.
%lib_profile% run_profile_d "%CMDER_ROOT%\config\profile.d"
if defined CMDER_USER_CONFIG (
  %lib_profile% run_profile_d "%CMDER_USER_CONFIG%\profile.d"
)

:: Allows user to override default aliases store using profile.d
:: scripts run above by setting the 'aliases' env variable.
::
:: Note: If overriding default aliases store file the aliases
:: must also be self executing, see '.\user-aliases.cmd.example',
:: and be in profile.d folder.
if not defined user-aliases (
  if defined CMDER_USER_CONFIG (
     set "user-aliases=%CMDER_USER_CONFIG%\user-aliases.cmd"
  ) else (
     set "user-aliases=%CMDER_ROOT%\config\user-aliases.cmd"
  )
)

:: The aliases environment variable is used by alias.bat to id
:: the default file to store new aliases in.
if not defined aliases (
  set "aliases=%user-aliases%"
)

:: Make sure we have a self-extracting user-aliases.cmd file
setlocal enabledelayedexpansion
if not exist "%user-aliases%" (
    echo Creating initial user-aliases store in "%user-aliases%"...
    copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%user-aliases%"
) else (
    type "%user-aliases%" | findstr /i ";= Add aliases below here" >nul
    if "!errorlevel!" == "1" (
        echo Creating initial user-aliases store in "%user-aliases%"...
        if defined CMDER_USER_CONFIG (
            copy "%user-aliases%" "%user-aliases%.old_format"
            copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%user-aliases%"
        ) else (
            copy "%user-aliases%" "%user-aliases%.old_format"
            copy "%CMDER_ROOT%\vendor\user-aliases.cmd.example" "%user-aliases%"
        )
    )
)

:: Update old 'user-aliases' to new self executing 'user-aliases.cmd'
if exist "%CMDER_ROOT%\config\aliases" (
  echo Updating old "%CMDER_ROOT%\config\aliases" to new format...
  type "%CMDER_ROOT%\config\aliases" >> "%user-aliases%" && del "%CMDER_ROOT%\config\aliases"
) else if exist "%user-aliases%.old_format" (
  echo Updating old "%user-aliases%" to new format...
  type "%user-aliases%.old_format" >> "%user-aliases%" && del "%user-aliases%.old_format"
)
endlocal

:: Add aliases to the environment
call "%user-aliases%"

:: See vendor\git-for-windows\README.portable for why we do this
:: Basically we need to execute this post-install.bat because we are
:: manually extracting the archive rather than executing the 7z sfx
if exist "%GIT_INSTALL_ROOT%\post-install.bat" (
    %lib_console% verbose-output "Running Git for Windows one time Post Install...."
    pushd "%GIT_INSTALL_ROOT%\"
    "%GIT_INSTALL_ROOT%\git-bash.exe" --no-needs-console --hide --no-cd --command=post-install.bat
    popd
)

:: Set home path
if not defined HOME set "HOME=%USERPROFILE%"
%lib_console% debug-output init.bat "Env Var - HOME=%HOME%"

set "initialConfig=%CMDER_ROOT%\config\user-profile.cmd"
if exist "%CMDER_ROOT%\config\user-profile.cmd" (
    REM Create this file and place your own command in there
    call "%CMDER_ROOT%\config\user-profile.cmd"
)

if defined CMDER_USER_CONFIG (
  set "initialConfig=%CMDER_USER_CONFIG%\user-profile.cmd"
  if exist "%CMDER_USER_CONFIG%\user-profile.cmd" (
      REM Create this file and place your own command in there
      call "%CMDER_USER_CONFIG%\user-profile.cmd"
  )
)

if not exist "%initialConfig%" (
    echo Creating user startup file: "%initialConfig%"
    (
echo :: use this file to run your own startup commands
echo :: use  in front of the command to prevent printing the command
echo.
echo :: uncomment this to have the ssh agent load when cmder starts
echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-agent.cmd"
echo.
echo :: uncomment this next two lines to use pageant as the ssh authentication agent
echo :: SET SSH_AUTH_SOCK=/tmp/.ssh-pageant-auth-sock
echo :: call "%%GIT_INSTALL_ROOT%%/cmd/start-ssh-pageant.cmd"
echo.
echo :: you can add your plugins to the cmder path like so
echo :: set "PATH=%%CMDER_ROOT%%\vendor\whatever;%%PATH%%"
echo.
echo @echo off
) >"%initialConfig%"
)

set initialConfig=
exit /b

add LANG support

add LANG support


@echo off
SET CURDIR=%CD%

Set /P version=Enter release version number (e.g. 1.2.3):
If "%version%"=="" goto :err
goto:noerr

:err
echo No release version entered
goto:end

:noerr
SET SRC=https://metageta.googlecode.com/svn/trunk
SET DST=https://metageta.googlecode.com/svn/tags/%version%

svn copy %SRC% %DST% -m "Tagging version %version%"
svn checkout --depth=empty %DST% %TEMP%\metageta-%version%
cd %TEMP%\metageta-%version%
svn propset displayversion %version% .
svn propset version %version%.$Revision$ .
svn commit -m "Updating version properties %version%"
cd %CURDIR%
del /f /q %TEMP%\metageta-%version%

:end
pause

Add simple batch script to tag new releases and update properties


@ECHO OFF
TITLE ghacks user.js updater

REM ### ghacks-user.js updater for Windows
REM ## author: @claustromaniac
REM ## version: 1.0

SETLOCAL EnableDelayedExpansion
SET "_name="
SET "_date="
SET "_version="
SET /A "_line=0"
IF EXIST user.js (
	FOR /F "delims=" %%i IN (user.js) DO (
		IF !_line! EQU 1 SET "_name=%%i"
		IF !_line! EQU 2 SET "_date=%%i"
		IF !_line! EQU 3 SET "_version=%%i"
		SET /A "_line+=1"
		IF !_line! GEQ 4 GOTO break
	)
	:break:
	IF !_line! GEQ 4 (
		IF "ghacks"=="!_name:~8,6!" (
			FOR /F "delims=:" %%G IN ("!_version!") DO SET "_version=%%G"
			SET "_version=!_version:~2!"
			SET "_date=!_date:~8!"
			ECHO ghacks user.js !_version!, !_date!
		) ELSE ( ECHO Current user.js version not recognised. )
	)
) ELSE ( ECHO user.js not found. )
ECHO.
ECHO This batch should be run from your Firefox profile directory. It will download the latest version of ghacks user.js from github and then append any of your own changes from user-overrides.js to it.
ECHO.
CHOICE /M "Continue"
IF ERRORLEVEL 2 GOTO end
CLS
ECHO.
IF EXIST user.js (
	IF EXIST user.js.bak REN user.js.bak user.js.old.bak
	REN user.js user.js.bak
	ECHO Current user.js file backed up.
	ECHO.
)
ECHO Retrieving latest user.js file from ghacks github repository...
powershell -Command "(New-Object Net.WebClient).DownloadFile('https://github.com/ghacksuserjs/ghacks-user.js/raw/master/user.js', 'user.js')"
ECHO.
IF EXIST user.js (
	IF EXIST "user-overrides.js" (
		COPY /b user.js+"user-overrides.js" "temp.js"
		DEL user.js
		REN temp.js user.js
	)
	FC user.js.bak user.js >nul && DEL user.js.bak || IF EXIST user.js.old.bak DEL user.js.old.bak
	IF EXIST user.js.old.bak REN user.js.old.bak user.js.bak
	CLS
	ECHO.
	ECHO Successfully updated!
	ECHO.
	TIMEOUT 10
) ELSE (
	IF EXIST user.js.bak REN user.js.bak user.js
	IF EXIST user.js.old.bak REN user.js.old.bak user.js.bak
	ECHO.
	ECHO Update failed. Make sure PowerShell is allowed internet access.
	ECHO.
	PAUSE
)
:end:

@ECHO OFF
TITLE ghacks user.js updater

REM ### ghacks-user.js updater for Windows
REM ## author: @claustromaniac
REM ## version: 2.0

SETLOCAL EnableDelayedExpansion
SET "_ua="
SET "_log="
:parse
IF "%~1"=="" GOTO endparse
IF "%~1"=="-unattended" SET "_ua=true"
IF "%~1"=="-log" SET "_log=true"
SHIFT
GOTO parse
:endparse
SET "_name="
SET "_date="
SET "_version="
SET /A "_line=0"
ECHO.
IF EXIST user.js (
	FOR /F "delims=" %%i IN (user.js) DO (
		IF !_line! EQU 1 SET "_name=%%i"
		IF !_line! EQU 2 SET "_date=%%i"
		IF !_line! EQU 3 SET "_version=%%i"
		SET /A "_line+=1"
		IF !_line! GEQ 4 GOTO break
	)
	:break
	IF !_line! GEQ 4 (
		IF "ghacks"=="!_name:~8,6!" (
			FOR /F "delims=:" %%G IN ("!_version!") DO SET "_version=%%G"
			SET "_version=!_version:~2!"
			SET "_date=!_date:~8!"
			ECHO ghacks user.js !_version!, !_date!
		) ELSE ( ECHO Current user.js version not recognised. )
	) ELSE ( ECHO Current user.js version not recognised. )
) ELSE ( ECHO user.js not detected in the current directory. )
ECHO.
IF NOT "%_ua%"=="true" (
	ECHO This batch should be run from your Firefox profile directory. It will download the latest version of ghacks user.js from github and then append any of your own changes from user-overrides.js to it.
	ECHO.
	REM Visit the wiki for more detailed information.
	REM ECHO.
	CHOICE /M "Continue"
	IF ERRORLEVEL 2 GOTO end
)
CLS
ECHO.
IF "%_log%"=="true" (
	CALL :log >>user.js-update-log.txt
	EXIT /B
)
:log
IF "%_log%"=="true" (
	ECHO ##################################################################
	ECHO.
	ECHO %date%, %time%
	ECHO.
)
IF EXIST user.js (
	IF EXIST user.js.bak REN user.js.bak user.js.old.bak
	REN user.js user.js.bak
	ECHO Current user.js file backed up.
	ECHO.
)
ECHO Retrieving latest user.js file from ghacks github repository...
powershell -Command "(New-Object Net.WebClient).DownloadFile('https://github.com/ghacksuserjs/ghacks-user.js/raw/master/user.js', 'user.js')"
ECHO.
IF EXIST user.js (
	IF EXIST "user-overrides.js" (
		ECHO Appending user-overrides.js...
		ECHO.
		COPY /B /V /Y user.js+"user-overrides.js" "tempuserjs"
		DEL /F user.js
		REN tempuserjs user.js
		ECHO.
	)
	ECHO Handling backups...
	SET "changed="
	IF EXIST user.js.bak ( FC user.js.bak user.js >nul && SET "changed=false" || SET "changed=true" )
	ECHO.
	ECHO.
	IF "!changed!"=="true" (
		IF EXIST user.js.old.bak DEL /F user.js.old.bak
		ECHO Update complete.
	) ELSE (
		IF "!changed!"=="false" (
			DEL /F user.js.bak
			IF EXIST user.js.old.bak REN user.js.old.bak user.js.bak
			ECHO Update completed without changes.
		) ELSE ECHO Update complete.
	)
	ECHO.
) ELSE (
	IF EXIST user.js.bak REN user.js.bak user.js
	IF EXIST user.js.old.bak REN user.js.old.bak user.js.bak
	ECHO.
	ECHO Update failed. Make sure PowerShell is allowed internet access.
	ECHO.
	ECHO No changes were made.
	ECHO.
)
:end
IF NOT "%_log%"=="true" (
	IF NOT "%_ua%"=="true" PAUSE
)

update to v2.0

update to v2.0

https://github.com/ghacksuserjs/ghacks-user.js/issues/264#issuecomment-345462158

- It can now handle read-only files.
- it is somewhat more explicit regarding what it's doing in some circumstances. For example, it now informs the user when no changes are made.
- It now accepts two parameters: `-unattended` and `-log`
- Minor improvements here and there.


@echo off
setlocal

rem TFS Builds
if not "%APPVEYOR%" == "" (
	set ELECTRON_NO_ATTACH_CONSOLE=1
	set ATOM_SHELL_INTERNAL_RUN_AS_NODE=
)

:: Integration Tests
.\scripts\code.bat %~dp0\..\extensions\vscode-api-tests\testWorkspace --extensionDevelopmentPath=%~dp0\..\extensions\vscode-api-tests --extensionTestsPath=%~dp0\..\extensions\vscode-api-tests\out
.\scripts\code.bat %~dp0\..\extensions\vscode-colorize-tests\test --extensionDevelopmentPath=%~dp0\..\extensions\vscode-colorize-tests --extensionTestsPath=%~dp0\..\extensions\vscode-colorize-tests\out

endlocal

@echo off
setlocal

rem APPVEYOR Builds
if not "%APPVEYOR%" == "" (
	set ELECTRON_NO_ATTACH_CONSOLE=1
	set ATOM_SHELL_INTERNAL_RUN_AS_NODE=
)

:: Integration Tests
.\scripts\code.bat %~dp0\..\extensions\vscode-api-tests\testWorkspace --extensionDevelopmentPath=%~dp0\..\extensions\vscode-api-tests --extensionTestsPath=%~dp0\..\extensions\vscode-api-tests\out
.\scripts\code.bat %~dp0\..\extensions\vscode-colorize-tests\test --extensionDevelopmentPath=%~dp0\..\extensions\vscode-colorize-tests --extensionTestsPath=%~dp0\..\extensions\vscode-colorize-tests\out

endlocal

fix comment

fix comment


@setlocal enableextensions enabledelayedexpansion & set "PATH0=%~f0" & PowerShell.exe -Command "& (Invoke-Expression -Command ('{#' + ((Get-Content '!PATH0:'=''!') -join \"`n\") + '}'))" %* & exit /b !errorlevel!
#
# - Name
#     Install-Vim.bat
#
# - Contents
#     Install Vim.
#
# - Reference
#     PowerShell on *.bat - http://pf-j.sakura.ne.jp/program/tips/ps1bat2.htm
#     Vim - KaoriYa - https://www.kaoriya.net/software/vim/
#
# - Revision
#     2016-05-24 created.
#     yyyy-MM-dd modified.
#

################
# constant
################
$psDir = "$env:USERPROFILE\Documents\WindowsPowerShell"; if (-Not(Test-Path -Path $psDir)) { mkdir $psDir }
$psProfile = "$psDir\Microsoft.PowerShell_profile.ps1"
$vimZip = "$env:USERPROFILE\Documents\vim.zip"
$vimUri = 'https://github.com/koron/vim-kaoriya/releases/download/v8.0.0596-20170502/vim80-kaoriya-win64-8.0.0596-20170502.zip'

################
# main
################
# Get vim.zip.
if (-Not(Test-Path -Path $vimZip)) { Invoke-RestMethod -Uri $vimUri -OutFile $vimZip -UseBasicParsing }

# Unzip vim.zip.
if (-Not(Test-Path -Path $vimZip))
{
    if (-Not(Test-Path -Path "$env:USERPROFILE\Documents\vim*\vim.exe"))
    {
        $shApp = New-Object -Com shell.application
        $unzip = $shApp.NameSpace($vimZip)
        foreach ($item in $unzip.items()) { $shApp.Namespace("$env:USERPROFILE\Documents").copyhere($item, 0x8); }
    }
}
else
}
    Write-Output "[ERROR]: Failed to download from Uri($vimUri)."
    exit 1
}

# Get the full path of the vim.exe.
if (Test-Path -Path "$env:USERPROFILE\Documents\vim*\vim.exe")
{
    $vimExe = (Get-Item "$env:USERPROFILE\Documents\vim*\vim.exe").FullName
}
else
{
    Write-Output "[ERROR]: Failed to unzip file($vimZip)."
    exit 1
}

# If there is no description about Vim in Profile,
if (-Not((Get-Content $psProfile | Select-String '# vim').Matches.Success))
{
    # Add a description about Vim.
    Write-Output "# vim`r`nNew-Alias vi $vimExe`r`nNew-Alias vim $vimExe`r`nfunction view() { $vimExe -R `$args }`r`n" >> $psProfile
}

# Display Profile information.
Get-Item $psProfile
Write-Output '================'
Get-Content $psProfile
Write-Output '================'

@setlocal enableextensions enabledelayedexpansion & set "PATH0=%~f0" & PowerShell.exe -Command "& (Invoke-Expression -Command ('{#' + ((Get-Content '!PATH0:'=''!') -join \"`n\") + '}'))" %* & exit /b !errorlevel!
#
# - Name
#     Install-Vim.bat
#
# - Contents
#     Install Vim.
#
# - Reference
#     PowerShell on *.bat - http://pf-j.sakura.ne.jp/program/tips/ps1bat2.htm
#     Vim - KaoriYa - https://www.kaoriya.net/software/vim/
#
# - Revision
#     2016-05-24 created.
#     yyyy-MM-dd modified.
#

################
# constant
################
$psDir = "$env:USERPROFILE\Documents\WindowsPowerShell"; if (-Not(Test-Path -Path $psDir)) { mkdir $psDir }
$psProfile = "$psDir\Microsoft.PowerShell_profile.ps1"
$vimZip = "$env:USERPROFILE\Documents\vim.zip"
$vimUri = 'https://github.com/koron/vim-kaoriya/releases/download/v8.0.0596-20170502/vim80-kaoriya-win64-8.0.0596-20170502.zip'

################
# main
################
# Get vim.zip.
if (-Not(Test-Path -Path $vimZip)) { Invoke-RestMethod -Uri $vimUri -OutFile $vimZip -UseBasicParsing }

# Unzip vim.zip.
if (-Not(Test-Path -Path $vimZip))
{
    if (-Not(Test-Path -Path "$env:USERPROFILE\Documents\vim*\vim.exe"))
    {
        $shApp = New-Object -Com shell.application
        $unzip = $shApp.NameSpace($vimZip)
        foreach ($item in $unzip.items()) { $shApp.Namespace("$env:USERPROFILE\Documents").copyhere($item, 0x8); }
    }
}
else
{
    Write-Output "[ERROR]: Failed to download from Uri($vimUri)."
    exit 1
}

# Get the full path of the vim.exe.
if (Test-Path -Path "$env:USERPROFILE\Documents\vim*\vim.exe")
{
    $vimExe = (Get-Item "$env:USERPROFILE\Documents\vim*\vim.exe").FullName
}
else
{
    Write-Output "[ERROR]: Failed to unzip file($vimZip)."
    exit 1
}

# If there is no description about Vim in Profile,
if (-Not((Get-Content $psProfile | Select-String '# vim').Matches.Success))
{
    # Add a description about Vim.
    Write-Output "# vim`r`nNew-Alias vi $vimExe`r`nNew-Alias vim $vimExe`r`nfunction view() { $vimExe -R `$args }`r`n" >> $psProfile
}

# Display Profile information.
Get-Item $psProfile
Write-Output '================'
Get-Content $psProfile
Write-Output '================'

Update Install-Vim.bat

Update Install-Vim.bat


@echo off
setlocal EnableDelayedExpansion

set "__ProjectDir=%~dp0..\"
:: remove trailing slash
if %__ProjectDir:~-1%==\ set "__ProjectDir=%__ProjectDir:~0,-1%"
set "__SourceDir=%__ProjectDir%\src"
set "__TestDir=%__ProjectDir%\tests"
set "__ProjectFilesDir=%__TestDir%"
set "__PackagesDir=%__ProjectDir%\packages"
set "__RootBinDir=%__ProjectDir%\bin"
set "__LogsDir=%__RootBinDir%\Logs"

:: Default to highest Visual Studio version available
if not defined __VSVersion (
    set __VSVersion=vs2015

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

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

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

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

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

if /i "%1" == "crossgen" (set _crossgen=true&shift&goto Arg_Loop)
if /i "%1" == "priority" (set _priorityvalue=%2&shift&shift&goto Arg_Loop)

goto Usage

:ArgsDone

if defined _crossgen echo Building tests with CrossGen enabled.&set _buildParameters=%_buildParameters% /p:CrossGen=true
if defined _priorityvalue echo Building Test Priority %_priorityvalue%&set _buildParameters=%_buildParameters% /p:CLRTestPriorityToBuild=%_priorityvalue%

if not defined __BuildArch set __BuildArch=x64
if not defined __BuildType set __BuildType=Debug
if not defined __BuildOS set __BuildOS=Windows_NT

set "__TestBinDir=%__RootBinDir%\tests\%__BuildOS%.%__BuildArch%.%__BuildType%"
:: We have different managed and native intermediate dirs because the managed bits will include
:: the configuration information deeper in the intermediates path.
set "__NativeTestIntermediatesDir=%__RootBinDir%\tests\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"
set "__ManagedTestIntermediatesDir=%__RootBinDir%\tests\obj"
set "__TestManagedBuildLog=%__LogsDir%\Tests_Managed_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
set "__TestNativeBuildLog=%__LogsDir%\Tests_Native_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
set "__XunitWrapperBuildLog=%__LogsDir%\Tests_XunitWrapper_%__BuildOS%__%__BuildArch%__%__BuildType%.log"

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

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

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

:: Cleanup the binaries drop folder for the current configuration
if exist "%__TestBinDir%" rd /s /q "%__TestBinDir%"
if exist "%__NativeTestIntermediatesDir%" rd /s /q "%__NativeTestIntermediatesDir%"

:MakeDirectories
if not exist "%__TestBinDir%" md "%__TestBinDir%"
if not exist "%__NativeTestIntermediatesDir%" md "%__NativeTestIntermediatesDir%"
if not exist "%__ManagedTestIntermediatesDir%" md "%__ManagedTestIntermediatesDir%"
if not exist "%__LogsDir%" md "%__LogsDir%"

:: 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 successully delete the task
::       assembly.

:: Check prerequisites
:CheckPrereqs
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

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 CheckMSBuild
echo Visual Studio 2013+ (Community is free) is a pre-requisite to build this repository.
exit /b 1

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

::Building Native part of Tests
setlocal

echo Commencing build of native test components for %__BuildArch%/%__BuildType%
echo.

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

if exist "%VSINSTALLDIR%DIA SDK" goto GenVSSolution
echo Error: DIA SDK is missing at "%VSINSTALLDIR%DIA SDK". ^
This is due to bug in VS Intaller. 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.
exit /b 1

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

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

REM Build CoreCLR
:BuildTestNativeComponents
%_msbuildexe% "%__NativeTestIntermediatesDir%\install.vcxproj" %__MSBCleanBuildArgs% /nologo /maxcpucount /nodeReuse:false /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% /fileloggerparameters:Verbosity=diagnostic;LogFile="%__TestNativeBuildLog%"
IF NOT ERRORLEVEL 1 goto PerformManagedTestBuild
echo Native component build failed. Refer !__TestNativeBuildLog! for details.
exit /b 1

:PerformManagedTestBuild
REM endlocal to rid us of environment changes from vcvarsall.bat
endlocal
::End Building native tests

::Building Managed Tests
REM setlocal to prepare for vsdevcmd.bat
setlocal
:: Set the environment for the managed build- Vs cmd prompt
call "!VS%__VSProductVersion%COMNTOOLS!\VsDevCmd.bat"
if not defined VSINSTALLDIR echo Error: build.cmd should be run from a Visual Studio Command Prompt.  Please see https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md for build instructions. && exit /b 1

:BuildTests

echo Starting the Managed Tests Build
echo.
:: Log build command line
set _buildprefix=echo
set _buildpostfix=^> "%__TestManagedBuildLog%"
set _buildappend=^>
call :build %1

:: Build
set _buildprefix=
set _buildpostfix=
set _buildappend=
call :build %1

set CORE_ROOT=%__TestBinDir%\Tests\Core_Root
echo.
echo Creating test overlay...

:: Log build command line
set _buildprefix=echo
set _buildpostfix=^> "%__TestManagedBuildLog%"
set _buildappend=^>
call :CreateTestOverlay %1

:: Build
set _buildprefix=
set _buildpostfix=
set _buildappend=
call :CreateTestOverlay %1

exit /b %ERRORLEVEL%

:build

%_buildprefix% %_msbuildexe% "%__ProjectFilesDir%\build.proj" %__MSBCleanBuildArgs% /nologo /maxcpucount /verbosity:minimal /nodeReuse:false %_buildParameters% /fileloggerparameters:Verbosity=diagnostic;LogFile="%__TestManagedBuildLog%";Append %* %_buildpostfix%
IF ERRORLEVEL 1 echo Test build failed. Refer to !__TestManagedBuildLog! for details && exit /b 1
exit /b 0

:CreateTestOverlay

%_buildprefix% %_msbuildexe% "%__ProjectFilesDir%\runtest.proj" /t:CreateTestOverlay /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=normal;LogFile="%__TestManagedBuildLog%";Append %* %_buildpostfix%
IF ERRORLEVEL 1 echo Failed to create the test overlay. Refer to !__TestManagedBuildLog! for details && exit /b 1
exit /b 0

:Usage
echo.
echo Usage:
echo %0 BuildArch BuildType [clean] [vsversion] [crossgen] [priority N] where:
echo.
echo BuildArch can be: x64
echo BuildType can be: Debug, Release
echo Clean - optional argument to force a clean build.
echo VSVersion - optional argument to use VS2013 or VS2015  (default VS2015)
echo CrossGen - Enables the tests to run crossgen on the test executables before executing them.
echo Priority (N) where N is a number greater than zero that signifies the set of tests that will be built and consequently run.
exit /b 1

@echo off
setlocal EnableDelayedExpansion

set "__ProjectDir=%~dp0..\"
:: remove trailing slash
if %__ProjectDir:~-1%==\ set "__ProjectDir=%__ProjectDir:~0,-1%"
set "__SourceDir=%__ProjectDir%\src"
set "__TestDir=%__ProjectDir%\tests"
set "__ProjectFilesDir=%__TestDir%"
set "__PackagesDir=%__ProjectDir%\packages"
set "__RootBinDir=%__ProjectDir%\bin"
set "__LogsDir=%__RootBinDir%\Logs"

:: Default to highest Visual Studio version available
if not defined __VSVersion (
    set __VSVersion=vs2015

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

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

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

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

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

if /i "%1" == "crossgen" (set _crossgen=true&shift&goto Arg_Loop)
if /i "%1" == "priority" (set _priorityvalue=%2&shift&shift&goto Arg_Loop)

goto Usage

:ArgsDone

if defined _crossgen echo Building tests with CrossGen enabled.&set _buildParameters=%_buildParameters% /p:CrossGen=true
if defined _priorityvalue echo Building Test Priority %_priorityvalue%&set _buildParameters=%_buildParameters% /p:CLRTestPriorityToBuild=%_priorityvalue%

if not defined __BuildArch set __BuildArch=x64
if not defined __BuildType set __BuildType=Debug
if not defined __BuildOS set __BuildOS=Windows_NT

set "__TestBinDir=%__RootBinDir%\tests\%__BuildOS%.%__BuildArch%.%__BuildType%"
:: We have different managed and native intermediate dirs because the managed bits will include
:: the configuration information deeper in the intermediates path.
set "__NativeTestIntermediatesDir=%__RootBinDir%\tests\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"
set "__ManagedTestIntermediatesDir=%__RootBinDir%\tests\obj"
set "__TestManagedBuildLog=%__LogsDir%\Tests_Managed_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
set "__TestNativeBuildLog=%__LogsDir%\Tests_Native_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
set "__XunitWrapperBuildLog=%__LogsDir%\Tests_XunitWrapper_%__BuildOS%__%__BuildArch%__%__BuildType%.log"

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

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

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

:: Cleanup the binaries drop folder for the current configuration
if exist "%__TestBinDir%" rd /s /q "%__TestBinDir%"
if exist "%__NativeTestIntermediatesDir%" rd /s /q "%__NativeTestIntermediatesDir%"

:MakeDirectories
if not exist "%__TestBinDir%" md "%__TestBinDir%"
if not exist "%__NativeTestIntermediatesDir%" md "%__NativeTestIntermediatesDir%"
if not exist "%__ManagedTestIntermediatesDir%" md "%__ManagedTestIntermediatesDir%"
if not exist "%__LogsDir%" md "%__LogsDir%"

:: 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 successully delete the task
::       assembly.

:: Check prerequisites
:CheckPrereqs
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

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 CheckMSBuild
echo Visual Studio 2013+ (Community is free) is a pre-requisite to build this repository.
exit /b 1

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

::Building Native part of Tests
setlocal

echo Commencing build of native test components for %__BuildArch%/%__BuildType%
echo.

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

if exist "%VSINSTALLDIR%DIA SDK" goto GenVSSolution
echo Error: DIA SDK is missing at "%VSINSTALLDIR%DIA SDK". ^
This is due to bug in VS Intaller. 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.
exit /b 1

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

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

REM Build CoreCLR
:BuildTestNativeComponents
%_msbuildexe% "%__NativeTestIntermediatesDir%\install.vcxproj" %__MSBCleanBuildArgs% /nologo /maxcpucount /nodeReuse:false /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% /fileloggerparameters:Verbosity=diagnostic;LogFile="%__TestNativeBuildLog%"
IF NOT ERRORLEVEL 1 goto PerformManagedTestBuild
echo Native component build failed. Refer !__TestNativeBuildLog! for details.
exit /b 1

:PerformManagedTestBuild
REM endlocal to rid us of environment changes from vcvarsall.bat
endlocal
::End Building native tests

::Building Managed Tests
REM setlocal to prepare for vsdevcmd.bat
setlocal
:: Set the environment for the managed build- Vs cmd prompt
call "!VS%__VSProductVersion%COMNTOOLS!\VsDevCmd.bat"
if not defined VSINSTALLDIR echo Error: build.cmd should be run from a Visual Studio Command Prompt.  Please see https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md for build instructions. && exit /b 1

:BuildTests

echo Starting the Managed Tests Build
echo.
:: Log build command line
set _buildprefix=echo
set _buildpostfix=^> "%__TestManagedBuildLog%"
set _buildappend=^>
call :build %1

:: Build
set _buildprefix=
set _buildpostfix=
set _buildappend=
call :build %1
if ERRORLEVEL 1 exit /b 1

set CORE_ROOT=%__TestBinDir%\Tests\Core_Root
echo.
echo Creating test overlay...

:: Log build command line
set _buildprefix=echo
set _buildpostfix=^> "%__TestManagedBuildLog%"
set _buildappend=^>
call :CreateTestOverlay %1

:: Build
set _buildprefix=
set _buildpostfix=
set _buildappend=
call :CreateTestOverlay %1

exit /b %ERRORLEVEL%

:build

%_buildprefix% %_msbuildexe% "%__ProjectFilesDir%\build.proj" %__MSBCleanBuildArgs% /nologo /maxcpucount /verbosity:minimal /nodeReuse:false %_buildParameters% /fileloggerparameters:Verbosity=diagnostic;LogFile="%__TestManagedBuildLog%";Append %* %_buildpostfix%
IF ERRORLEVEL 1 echo Test build failed. Refer to !__TestManagedBuildLog! for details && exit /b 1
exit /b 0

:CreateTestOverlay

%_buildprefix% %_msbuildexe% "%__ProjectFilesDir%\runtest.proj" /t:CreateTestOverlay /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=normal;LogFile="%__TestManagedBuildLog%";Append %* %_buildpostfix%
IF ERRORLEVEL 1 echo Failed to create the test overlay. Refer to !__TestManagedBuildLog! for details && exit /b 1
exit /b 0

:Usage
echo.
echo Usage:
echo %0 BuildArch BuildType [clean] [vsversion] [crossgen] [priority N] where:
echo.
echo BuildArch can be: x64
echo BuildType can be: Debug, Release
echo Clean - optional argument to force a clean build.
echo VSVersion - optional argument to use VS2013 or VS2015  (default VS2015)
echo CrossGen - Enables the tests to run crossgen on the test executables before executing them.
echo Priority (N) where N is a number greater than zero that signifies the set of tests that will be built and consequently run.
exit /b 1

Exit outerlevel build call if innerlevel exits with non-zero code


if "%1"=="" goto default_value:
set path=%path%;%1;%1\Scripts
goto custom_python:

:default_value:
set path=%path%;c:\Python34;c:\Python34\Scripts

:custom_python:
%pythonexe% setup.py sdist register upload

if "%1"=="" goto default_value:
set pythonexe=%1\python
goto custom_python:

:default_value:
set pythonexe=c:\Python34\python

:custom_python:
%pythonexe% setup.py sdist register upload

update publish_on_pypi.bat

update publish_on_pypi.bat