@echo off
:##############################################################################
:#                                                                            #
:#  Filename        2note2.bat                                                #
:#                                                                            #
:#  Description     Pipe data into Notepad2.exe                               #
:#                                                                            #
:#  Notes 	                                                              #
:#                                                                            #
:#  Author          Jean-Franois Larvoire, jf.larvoire@hpe.com               #
:#                                                                            #
:#  History                                                                   #
:#   2019-10-24 JFL Create this script.                                       #
:#   2022-06-27 JFL Fix the issue with the extra CRLF appended to the text.   #
:#		                                                              #
:##############################################################################

:# Rerun self in a sub-shell, to avoid breaking the original shell file handles
echo %0 | findstr :: >nul || (cmd /d /c ^""%~dp0\::\..\%~nx0" %*^" & exit /b)

setlocal EnableExtensions EnableDelayedExpansion
set "VERSION=2022-06-27"
set "SCRIPT=%~nx0"		&:# Script name
set "SNAME=%~n0"		&:# Script name, without its extension
set "SPATH=%~dp0"		&:# Script path
set "SPATH=%SPATH:~0,-1%"	&:# Script path, without the trailing \
set "SFULL=%~f0"		&:# Script full pathname
set ^"ARG0=%0^"			&:# Script invokation name
set ^"ARGS=%*^"			&:# Argument line

call :debug.init
goto :Main

:debug.init
set "IFDEBUG=if "%DEBUG%"=="1""
set "ECHO.D=%IFDEBUG% echo"
set "ECHOVARS.D=%IFDEBUG% call :echovars"
set "RETURN=exit /b"
exit /b

:echovars %*=variables names
setlocal EnableExtensions EnableDelayedExpansion
for %%s in (%*) do echo set "%%s=!%%s!"
endlocal & exit /b

:#----------------------------------------------------------------------------#
:# Sleep N seconds. %1 = Number of seconds to wait.
:Sleep
%FUNCTION%
set /A N=%1+1
ping -n %N% 127.0.0.1 >NUL 2>&1
%RETURN%

:#----------------------------------------------------------------------------#

:# Note: In the routines below, we call "lists" batch variables with elements separated by a space.
:# The advantage of such lists is that they can be parsed, or looped on, using just the "for" command.
:# We build lists in a way that inserts an extra space ahead of the first element.
:# For performance reasons, we do not bother removing that space all along.
:# We remove it only in the final list returned in the end.
:# Also, we rely on the fact that elements in a list of handles here are all 1-digit numbers.

:#----------------------------------------------------------------------------#
:# Handle enumeration routine - Return lists of used and free file I/O handles
:EnumHandles %1=freeListVar %2=usedListVar %3=quantumLevelVar %4=knownList (Not including 0 1 2)
:#	     Returns %freeHandles%, %usedHandles%, %nUnknownHandles%
setlocal EnableExtensions EnableDelayedExpansion
%ECHO.D% call %0 %*

:# Search the top free handles
:# Our :TryRedir routine uses 2>NUL, so itself always uses the first free handle.
:# => Handle 3 will always be found in use: Either it was already, or 2>NUL will use it.
:# Using handle 3 for redirection tests forces cmd.exe to use the second free handle to save it.
:# => Handle 4 will always be found in use: Either it was already, or 3>&%%h will use it.
:# Try duplicating handles 5 to 9, to see if they exist.
set "freeHandles="	&:# List of free file handles
set "usedHandles= 3 4"	&:# List of used file handles. 3 and 4 will be in use.
for /L %%h in (5,1,9) do call :TryRedir 3 %%h freeHandles usedHandles
%ECHOVARS.D% freeHandles usedHandles

:# Search the second missed free handle, used for saving handle 3 above
if defined freeHandles ( :# This can only work by using another free handle
  set "firstFreeHandle=!freeHandles:~1,1!" &:# The first free one we've found so far
  set /a "tryLast=firstFreeHandle-1" &:# The last used handle before the first free one
  set "freeHandle="	&:# 1-element list with the free handle we missed in the above loop
  :# Again, no need to test handle 3, it's bound to be found in use.
  for /L %%h in (4,1,!tryLast!) do if not defined freeHandle call :TryRedir !firstFreeHandle! %%h freeHandle usedHandles2
  :# Move that free handle from the used list to the free list
  for %%h in ("!freeHandle!") do set "usedHandles=!usedHandles:%%~h=!"
  set "freeHandles=!freeHandle!!freeHandles!"
)
%ECHOVARS.D% freeHandles usedHandles

:# Search the first missed free handle, used for saving handle 2 above
:# If the first used handle is followed by the first free handle, then we know
:# it's the one that was used by the 2>NUL redirection. So it's actually free.
:# More generally, if all used handles before the first free one are known used
:# handles passed in %4, except for one, then that unknown one is actually free.
if defined freeHandles ( :# [Else there may actually be two unknown handles]
  set "firstFreeHandle=!freeHandles:~1,1!" &:# The first free one we've found so far
  set "knownUsedHandles=%~4" &:# This list may be empty, or partial
  set /a "nUnknownHandles=firstFreeHandle-3"
  %ECHOVARS.D% firstFreeHandle nUnknownHandles knownUsedHandles
  set "unknownHandles="
  set /a "tryLast=firstFreeHandle-1"
  for /l %%h in (3,1,!tryLast!) do set "unknownHandles=!unknownHandles! %%h"
  if defined knownUsedHandles for %%h in (!knownUsedHandles!) do (
    if %%h lss !firstFreeHandle! ( :# Then remove it from the unknown handle list
      set /a "nUnknownHandles-=1"
      set "unknownHandles=!unknownHandles: %%h=!"
    )
  )
  %ECHOVARS.D% nUnknownHandles unknownHandles
  if !nUnknownHandles!==1 (  :# OK, this single used handle is actually free.
    :# Move it from the used list to the free list
    for %%h in ("!unknownHandles!") do set "usedHandles=!usedHandles:%%~h=!"
    set "freeHandles=!unknownHandles!%freeHandles%"
    set "quantumLevel=0"
  ) else ( :# One unidentified handle in the used list is actually free.
    set "quantumLevel=1"
  )
) else ( :# No free handle found. Up to 2 used handles may actually be free.
  set "quantumLevel=2"
)
:# Cleanup and return
for %%v in (freeHandles usedHandles) do if defined %%v set "%%v=!%%v:~1!" &:# Remove the head space
endlocal & (
  set "%1=%freeHandles%"
  set "%2=%usedHandles%"
  set "%3=%quantumLevel%"
  %ECHOVARS.D% freeHandles usedHandles quantumLevel
) & (%ECHO.D% return %ERRORLEVEL%) & exit /b

:TryRedir %1=Handle to redirect; %2=Handle to duplicate; %3=Free var; %4=Used var
2>NUL ( :# Prevent error messages written to stderr from being visible.
  break %1>&%2 && (	:# The redirection succeeded.
    set "%4=!%4! %2"	&rem The handle %2 existed. Add it to the used list.
    (call,)		&rem Clear ERRORLEVEL, which might be non-0 despite success here.
  ) || (		:# The redirection failed, and an error message was written to stderr.
    set "%3=!%3! %2"	&rem The handle %2 did not exit. Add it to the free list.
  )
)
exit /b	  &:# Returns 0=Used, 1=Free

:#----------------------------------------------------------------------------#
:# Pipe creation routine - Returns the two handles selected, and updates the known handles list
:CreatePipe %1=PipeIn name; %2=PipeOut name; %3=Known handles list name (optional, list may be partial)
setlocal EnableExtensions EnableDelayedExpansion
%ECHO.D% call %0 %*
if not "%3"=="" (set "knownHandles=!%3!") else (set "knownHandles=")
call :EnumHandles freeHandles usedHandles quantumLevel "%knownHandles%"
:# Make sure there are at least 4 free handles. The list looks like: "0 2 4 6"
if %quantumLevel% gtr 1 endlocal & exit /b 1	 &:# No free handles
if "%freeHandles:~6,1%"=="" endlocal & exit /b 1 &:# Not enough free handles
:# Define an optional redirection, that plugs the hole in the usedHandles list, if any
set "FILL_HOLE="
if %quantumLevel% equ 1 set "FILL_HOLE=2>NUL"
:# Select the handles to use, in the first four free handles left
for /f "tokens=1,2,4" %%a in ("%freeHandles%") do (
  set "hIn=%%a"			&:# PipeIn handle
  set "hOut=%%b"		&:# PipeOut handle
  set "hTmp=%%c"		&rem Temporary handle, released after use
)
%ECHOVARS.D% hIn hOut hTmp
endlocal & (
  set "%1=%hIn%"		&:# PipeIn handle
  set "%2=%hOut%"		&:# PipeOut handle
  if not "%3"=="" (
    set "%3=!%3! %hIn% %hOut%"
    %ECHOVARS.D% %3
  )
) & %FILL_HOLE% (rundll32 1>&%hOut% %hOut%>&%hTmp% | rundll32 0>&%hIn% %hIn%>&%hTmp%)
%ECHO.D% return %ERRORLEVEL%
exit /b

:#----------------------------------------------------------------------------#
:#                                                                            #
:#  Function        Main                                                      #
:#                                                                            #
:#  Description     Process command line arguments                            #
:#                                                                            #
:#  Arguments       %*	    Command line arguments                            #
:#                                                                            #
:#  Notes 	                                                              #
:#                                                                            #
:#  History                                                                   #
:#                                                                            #
:#----------------------------------------------------------------------------#

:Help
echo.
echo %SCRIPT% version %VERSION% - Pipe data into Notepad2.exe
echo.
echo Usage: ^<command^> ^| %SCRIPT% [OPTIONS]
echo.
echo Options:
echo   -?       Display this help
echo   -V       Display the script version and exit
goto :eof

:#----------------------------------------------------------------------------#
:# Main routine

:Main
goto :get_arg
:next_arg
shift
:get_arg
if [%1]==[] goto :Start
set "ARG=%~1"
if "!ARG!"=="-?" goto :Help
if "!ARG!"=="/?" goto :Help
if "!ARG!"=="-V" (echo.%VERSION%) & goto :eof
if "!ARG:~0,1!"=="-" (
  >&2 %ECHO% Warning: Unexpected option ignored: !ARG!
  goto :next_arg
)
>&2 %ECHO% Warning: Unexpected argument ignored: !"ARG"!
goto :next_arg

:#----------------------------------------------------------------------------#

:Start
:# Create a SUB variable containing a SUB <==> EOF <==> Ctrl-Z character
:# Not necessary anymore, now that 1clip.exe has a -Z option for generating a Ctrl-Z.
:# >NUL copy /y NUL + NUL /a "%TEMP%\1A.chr" /a
:# for /f %%c in (%TEMP%\1A.chr) do set "SUB=%%c"

call :CreatePipe P1IN P1OUT
if errorlevel 1 echo Error: Failed to find 4 free handles for pipe 1 & exit /b 1

:# Save the initial clipboard contents
>&%P1OUT% 1clip -U -Z
:# >&%P1OUT% echo.!SUB!

:# Pipe the standard input data into Notepad2
2clip -N	  &:# First pipe it into the clipboard, removing the final CRLF
start notepad2 -c &:# -c option tells Notepad2 to copy data from the clipboard
		   :# Known issue: -c appends an extra \n after the clipboard data!
		   :# 2clip.exe's -N option now compensates for that.

:# wait 1s, to give time to Notepad2 to start and paste the clipboard content
call :Sleep 1

:# Restore the initial clipboard contents
<&%P1IN% 2clip -U -z

@echo off
:##############################################################################
:#                                                                            #
:#  Filename        2note2.bat                                                #
:#                                                                            #
:#  Description     Pipe data into Notepad2.exe                               #
:#                                                                            #
:#  Notes 	                                                              #
:#                                                                            #
:#  Author          Jean-Franois Larvoire, jf.larvoire@hpe.com               #
:#                                                                            #
:#  History                                                                   #
:#   2019-10-24 JFL Create this script.                                       #
:#   2022-06-27 JFL Fix the issue with the extra CRLF appended to the text.   #
:#   2022-06-28 JFL Fix hangs with clipboard contents > 4KB.                  #
:#   2022-07-04 JFL Added option -p to revert to using a pipe if desired.     #
:#		    Added option -d to enable debugging on the command line.  #
:#		                                                              #
:##############################################################################

:# Rerun self in a sub-shell, to avoid breaking the original shell file handles
echo %0 | findstr :: >nul || (cmd /d /c ^""%~dp0\::\..\%~nx0" %*^" & exit /b)

setlocal EnableExtensions EnableDelayedExpansion
set "VERSION=2022-07-04"
set "SCRIPT=%~nx0"		&:# Script name
set "SNAME=%~n0"		&:# Script name, without its extension
set "SPATH=%~dp0"		&:# Script path
set "SPATH=%SPATH:~0,-1%"	&:# Script path, without the trailing \
set "SFULL=%~f0"		&:# Script full pathname
set ^"ARG0=%0^"			&:# Script invokation name
set ^"ARGS=%*^"			&:# Argument line

call :debug.init
goto :Main

:debug.init
set "IFDEBUG=if "%DEBUG%"=="1""
set "ECHO=echo"
set "ECHO.D=%IFDEBUG% echo"
set "ECHOVARS=call :echovars"
set "ECHOVARS.D=%IFDEBUG% call :echovars"
set "RETURN=exit /b"
exit /b

:echovars %*=variables names
setlocal EnableExtensions EnableDelayedExpansion
for %%s in (%*) do echo set "%%s=!%%s!"
endlocal & exit /b

:#----------------------------------------------------------------------------#
:# Sleep N seconds. %1 = Number of seconds to wait.
:Sleep
%FUNCTION%
set /A N=%1+1
ping -n %N% 127.0.0.1 >NUL 2>&1
%RETURN%

:#----------------------------------------------------------------------------#

:# Note: In the routines below, we call "lists" batch variables with elements separated by a space.
:# The advantage of such lists is that they can be parsed, or looped on, using just the "for" command.
:# We build lists in a way that inserts an extra space ahead of the first element.
:# For performance reasons, we do not bother removing that space all along.
:# We remove it only in the final list returned in the end.
:# Also, we rely on the fact that elements in a list of handles here are all 1-digit numbers.

:#----------------------------------------------------------------------------#
:# Handle enumeration routine - Return lists of used and free file I/O handles
:EnumHandles %1=freeListVar %2=usedListVar %3=quantumLevelVar %4=knownList (Not including 0 1 2)
:#	     Returns %freeHandles%, %usedHandles%, %nUnknownHandles%
setlocal EnableExtensions EnableDelayedExpansion
%ECHO.D% call %0 %*

:# Search the top free handles
:# Our :TryRedir routine uses 2>NUL, so itself always uses the first free handle.
:# => Handle 3 will always be found in use: Either it was already, or 2>NUL will use it.
:# Using handle 3 for redirection tests forces cmd.exe to use the second free handle to save it.
:# => Handle 4 will always be found in use: Either it was already, or 3>&%%h will use it.
:# Try duplicating handles 5 to 9, to see if they exist.
set "freeHandles="	&:# List of free file handles
set "usedHandles= 3 4"	&:# List of used file handles. 3 and 4 will be in use.
for /L %%h in (5,1,9) do call :TryRedir 3 %%h freeHandles usedHandles
%ECHOVARS.D% freeHandles usedHandles

:# Search the second missed free handle, used for saving handle 3 above
if defined freeHandles ( :# This can only work by using another free handle
  set "firstFreeHandle=!freeHandles:~1,1!" &:# The first free one we've found so far
  set /a "tryLast=firstFreeHandle-1" &:# The last used handle before the first free one
  set "freeHandle="	&:# 1-element list with the free handle we missed in the above loop
  :# Again, no need to test handle 3, it's bound to be found in use.
  for /L %%h in (4,1,!tryLast!) do if not defined freeHandle call :TryRedir !firstFreeHandle! %%h freeHandle usedHandles2
  :# Move that free handle from the used list to the free list
  for %%h in ("!freeHandle!") do set "usedHandles=!usedHandles:%%~h=!"
  set "freeHandles=!freeHandle!!freeHandles!"
)
%ECHOVARS.D% freeHandles usedHandles

:# Search the first missed free handle, used for saving handle 2 above
:# If the first used handle is followed by the first free handle, then we know
:# it's the one that was used by the 2>NUL redirection. So it's actually free.
:# More generally, if all used handles before the first free one are known used
:# handles passed in %4, except for one, then that unknown one is actually free.
if defined freeHandles ( :# [Else there may actually be two unknown handles]
  set "firstFreeHandle=!freeHandles:~1,1!" &:# The first free one we've found so far
  set "knownUsedHandles=%~4" &:# This list may be empty, or partial
  set /a "nUnknownHandles=firstFreeHandle-3"
  %ECHOVARS.D% firstFreeHandle nUnknownHandles knownUsedHandles
  set "unknownHandles="
  set /a "tryLast=firstFreeHandle-1"
  for /l %%h in (3,1,!tryLast!) do set "unknownHandles=!unknownHandles! %%h"
  if defined knownUsedHandles for %%h in (!knownUsedHandles!) do (
    if %%h lss !firstFreeHandle! ( :# Then remove it from the unknown handle list
      set /a "nUnknownHandles-=1"
      set "unknownHandles=!unknownHandles: %%h=!"
    )
  )
  %ECHOVARS.D% nUnknownHandles unknownHandles
  if !nUnknownHandles!==1 (  :# OK, this single used handle is actually free.
    :# Move it from the used list to the free list
    for %%h in ("!unknownHandles!") do set "usedHandles=!usedHandles:%%~h=!"
    set "freeHandles=!unknownHandles!%freeHandles%"
    set "quantumLevel=0"
  ) else ( :# One unidentified handle in the used list is actually free.
    set "quantumLevel=1"
  )
) else ( :# No free handle found. Up to 2 used handles may actually be free.
  set "quantumLevel=2"
)
:# Cleanup and return
for %%v in (freeHandles usedHandles) do if defined %%v set "%%v=!%%v:~1!" &:# Remove the head space
endlocal & (
  set "%1=%freeHandles%"
  set "%2=%usedHandles%"
  set "%3=%quantumLevel%"
  %ECHOVARS.D% freeHandles usedHandles quantumLevel
) & (%ECHO.D% return %ERRORLEVEL%) & exit /b

:TryRedir %1=Handle to redirect; %2=Handle to duplicate; %3=Free var; %4=Used var
2>NUL ( :# Prevent error messages written to stderr from being visible.
  break %1>&%2 && (	:# The redirection succeeded.
    set "%4=!%4! %2"	&rem The handle %2 existed. Add it to the used list.
    (call,)		&rem Clear ERRORLEVEL, which might be non-0 despite success here.
  ) || (		:# The redirection failed, and an error message was written to stderr.
    set "%3=!%3! %2"	&rem The handle %2 did not exit. Add it to the free list.
  )
)
exit /b	  &:# Returns 0=Used, 1=Free

:#----------------------------------------------------------------------------#
:# Pipe creation routine - Returns the two handles selected, and updates the known handles list
:CreatePipe %1=PipeIn name; %2=PipeOut name; %3=Known handles list name (optional, list may be partial)
setlocal EnableExtensions EnableDelayedExpansion
%ECHO.D% call %0 %*
if not "%3"=="" (set "knownHandles=!%3!") else (set "knownHandles=")
call :EnumHandles freeHandles usedHandles quantumLevel "%knownHandles%"
:# Make sure there are at least 4 free handles. The list looks like: "0 2 4 6"
if %quantumLevel% gtr 1 endlocal & exit /b 1	 &:# No free handles
if "%freeHandles:~6,1%"=="" endlocal & exit /b 1 &:# Not enough free handles
:# Define an optional redirection, that plugs the hole in the usedHandles list, if any
set "FILL_HOLE="
if %quantumLevel% equ 1 set "FILL_HOLE=2>NUL"
:# Select the handles to use, in the first four free handles left
for /f "tokens=1,2,4" %%a in ("%freeHandles%") do (
  set "hIn=%%a"			&:# PipeIn handle
  set "hOut=%%b"		&:# PipeOut handle
  set "hTmp=%%c"		&rem Temporary handle, released after use
)
%ECHOVARS.D% hIn hOut hTmp
endlocal & (
  set "%1=%hIn%"		&:# PipeIn handle
  set "%2=%hOut%"		&:# PipeOut handle
  if not "%3"=="" (
    set "%3=!%3! %hIn% %hOut%"
    %ECHOVARS.D% %3
  )
) & %FILL_HOLE% (rundll32 1>&%hOut% %hOut%>&%hTmp% | rundll32 0>&%hIn% %hIn%>&%hTmp%)
%ECHO.D% return %ERRORLEVEL%
exit /b

:#----------------------------------------------------------------------------#
:#                                                                            #
:#  Function        Main                                                      #
:#                                                                            #
:#  Description     Process command line arguments                            #
:#                                                                            #
:#  Arguments       %*	    Command line arguments                            #
:#                                                                            #
:#  Notes 	                                                              #
:#                                                                            #
:#  History                                                                   #
:#                                                                            #
:#----------------------------------------------------------------------------#

:Help
echo.
echo %SCRIPT% version %VERSION% - Pipe data into Notepad2.exe
echo.
echo Usage: ^<command^> ^| %SCRIPT% [OPTIONS]
echo.
echo Options:
echo   -?       Display this help
echo   -d       Debug mode
echo   -p       Use a pipe instead of a file for saving the clipboard content
echo   -V       Display the script version and exit
goto :eof

:#----------------------------------------------------------------------------#
:# Main routine

:Main
set "USE_PIPE=0"
goto :get_arg
:next_arg
shift
:get_arg
if [%1]==[] goto :Start
set "ARG=%~1"
if "!ARG!"=="-?" goto :Help
if "!ARG!"=="/?" goto :Help
if "!ARG!"=="-d" set "DEBUG=1" & call :debug.init & goto :next_arg
if "!ARG!"=="-p" set "USE_PIPE=1" & goto :next_arg
if "!ARG!"=="-V" (echo.%VERSION%) & goto :eof
if "!ARG:~0,1!"=="-" (
  >&2 %ECHO% Warning: Unexpected option ignored: !ARG!
  goto :next_arg
)
>&2 %ECHO% Warning: Unexpected argument ignored: %1
goto :next_arg

:#----------------------------------------------------------------------------#

:Start
:# Create a SUB variable containing a SUB <==> EOF <==> Ctrl-Z character
:# Not necessary anymore, now that 1clip.exe has a -Z option for generating a Ctrl-Z.
:# >NUL copy /y NUL + NUL /a "%TEMP%\1A.chr" /a
:# for /f %%c in (%TEMP%\1A.chr) do set "SUB=%%c"

:# Prepare saving the initial clipboard contents
if "%USE_PIPE%"=="1" (
  call :CreatePipe P1IN P1OUT
  if errorlevel 1 echo Error: Failed to find 4 free handles for pipe 1 & exit /b 1
) else (
  set "TEMPFILE=%TEMP%\2note2_%PID%_%RANDOM%_%TIME::=%.tmp"
)
:# Save the initial clipboard contents
:# Use a second if test for doing the actual save, because >&!P1OUT! in a (block) generates a syntax error.
if "%USE_PIPE%"=="1" (
  :# Saving the data in a pipe hangs if there is 4KB of data or more.
  >&%P1OUT% 1clip -U -Z
  rem :# >&%P1OUT% echo.!SUB!
) else (
  :# So instead of saving it in a pipe, save it by default in a temporary file.
  >"%TEMPFILE%" 1clip -U
)

:# Pipe the standard input data into Notepad2
2clip -N	  &:# First pipe it into the clipboard, removing the final CRLF
start notepad2 -c &:# -c option tells Notepad2 to copy data from the clipboard
		   :# Known issue: -c appends an extra \n after the clipboard data!
		   :# 2clip.exe's -N option now compensates for that.

:# wait 1s, to give time to Notepad2 to start and paste the clipboard content
call :Sleep 1

:# Restore the initial clipboard contents
if "%USE_PIPE%"=="1" (
  <&%P1IN% 2clip -U -z
) else (
  <"%TEMPFILE%" 2clip -U
  del "%TEMPFILE%"
)

Fix hangs with clipboard contents > 4KB. Added option -p to revert to using a pipe if desired. Added option -d to enable debugging on the command line.


SET MsBuildPath=C:\Windows\Microsoft.NET\Framework64\v4.0.30319
SET NuGetExe=.nuget\nuget.exe
%MsBuildPath%\MsBuild.exe build.proj

.nuget\NuGet.exe pack Caliburn.Metro\Caliburn.Metro.nuspec
.nuget\NuGet.exe pack Caliburn.Metro.Autofac\Caliburn.Metro.Autofac.nuspec

Add basic build and pack script

Add basic build and pack script


@echo setting up deploy dir
rd /S /Q deploy
md deploy
md deploy\d2d

@echo deploying
copy "%BUILDDIR%\d2d.exe" deploy\d2d\
copy "LICENSE" deploy\d2d\
rem copy "%QTDIR%\bin\libgcc_s_dw2-1.dll" deploy\d2d\
rem copy "%QTDIR%\bin\libstdc++-6.dll" deploy\d2d\
rem copy "%QTDIR%\bin\libwinpthread-1.dll" deploy\d2d\

windeployqt --compiler-runtime --dir deploy\d2d %BUILDDIR%\d2d.exe

dir deploy\
dir deploy\d2d
rem @echo compressing
rem cd deploy
rem zip -9 d2d.zip d2d\*
rem cd ..

set DEPLOY_NAME = "d2d-%PLATFORM%-%APPVEYOR_BUILD_VERSION%"

@echo setting up deploy dir
rd /S /Q deploy
md deploy
md deploy\%DEPLOY_NAME%

@echo deploying
copy "%BUILDDIR%\d2d.exe" deploy\%DEPLOY_NAME%\
copy "LICENSE" deploy\%DEPLOY_NAME%\
rem copy "%QTDIR%\bin\libgcc_s_dw2-1.dll" deploy\%DEPLOY_NAME%\
rem copy "%QTDIR%\bin\libstdc++-6.dll" deploy\%DEPLOY_NAME%\
rem copy "%QTDIR%\bin\libwinpthread-1.dll" deploy\%DEPLOY_NAME%\

windeployqt --compiler-runtime --dir deploy\%DEPLOY_NAME% %BUILDDIR%\d2d.exe

dir deploy\
dir deploy\%DEPLOY_NAME%
@echo compressing
cd deploy
7z a %DEPLOY_ZIP%.7z %DEPLOY_NAME%
cd ..

Update deploy.bat

Update deploy.bat


mkdir build
cd build

cp %SRC_DIR%\src\win7\drivers\IntelRealSense_D400_series_win7.inf %SRC_DIR%

cmake -GNinja ^
    -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
    -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
    -DCMAKE_BUILD_TYPE=Release ^
    -DCMAKE_INSTALL_LIBDIR=lib ^
    -DBUILD_SHARED_LIBS=ON ^
    -DENABLE_CCACHE=OFF ^
    -DBUILD_WITH_OPENMP=OFF ^
    -DFORCE_RSUSB_BACKEND=ON ^
    -DBUILD_EXAMPLES=OFF ^
    -DBUILD_UNIT_TESTS=OFF ^
    %SRC_DIR%
if errorlevel 1 exit 1

:: Build.
cmake --build . --config Release
if errorlevel 1 exit 1

:: Install.
cmake --build . --config Release --target install
if errorlevel 1 exit 1

mkdir build
cd build

cp %SRC_DIR%\src\win7\drivers\IntelRealSense_D400_series_win7.inf %SRC_DIR%

cmake -GNinja ^
    -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
    -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
    -DCMAKE_BUILD_TYPE=Release ^
    -DCMAKE_INSTALL_LIBDIR=lib ^
    -DBUILD_SHARED_LIBS=ON ^
    -DENABLE_CCACHE=OFF ^
    -DBUILD_WITH_OPENMP=OFF ^
    -DFORCE_RSUSB_BACKEND=ON ^
    -DBUILD_EXAMPLES=OFF ^
    -DBUILD_UNIT_TESTS=OFF ^
    -DLIBUSB_LIB=%LIBRARY_LIB%\libusb-1.0.lib ^
    %SRC_DIR%
if errorlevel 1 exit 1

:: Build.
cmake --build . --config Release
if errorlevel 1 exit 1

:: Install.
cmake --build . --config Release --target install
if errorlevel 1 exit 1

Update bld.bat

Update bld.bat


@echo off
:: set path to erlang installation

SETLOCAL ENABLEDELAYEDEXPANSION

set ERL_R16B03=5.10.4
set ERL_R16B02=5.10.3
set ERL_R16B01=5.10.2
set ERL_R16B=5.10.1
set ERL_R15B03_1=5.9.3.1
set ERL_R15B03=5.9.3
set ERL_R15B02=5.9.2
set ERL_R15B01=5.9.1
set ERL_R15B=5.9
set ERL_R14B04=5.8.5
set ERL_R14B03=5.8.4
set ERL_R14B02=5.8.3
set ERL_R14B01=5.8.2
set ERL_R14B=5.8.1
set ERL_R14A=5.8
set ERL_R13B04=5.7.5
set ERL_R13B03=5.7.4
set ERL_R13B02=5.7.3
set ERL_R13B01=5.7.2
set ERL_ALL=%ERL_R16B03% %ERL_R16B02% %ERL_R16B01% %ERL_R16B% %ERL_R15B03_1% %ERL_R15B03% %ERL_R15B02% %ERL_R15B01% %ERL_R15B% %ERL_R14B04% %ERL_R14B03% %ERL_R14B02% %ERL_R14B01% %ERL_R14B% %ERL_R14A% %ERL_R13B04% %ERL_R13B03% %ERL_R13B02% %ERL_R13B01%
if not defined ERLANG_HOME (
    FOR %%c in (%ERL_ALL%) DO (
        FOR %%p in ("%ProgramFiles%\erl%%c" "%ProgramFiles(x86)%\erl%%c") DO (
            set FULL_PATH=%%p
            if exist !FULL_PATH! (
                set ERLANG_HOME=%%p
                goto found
            )
        )
    )
)

:found

echo ERLANG_HOME=%ERLANG_HOME%

ENDLOCAL & set ERLANG_HOME=%ERLANG_HOME%

@echo off
:: set path to erlang installation

SETLOCAL ENABLEDELAYEDEXPANSION

set ERL_R17=6.0
set ERL_R16B03=5.10.4
set ERL_R16B02=5.10.3
set ERL_R16B01=5.10.2
set ERL_R16B=5.10.1
set ERL_R15B03_1=5.9.3.1
set ERL_R15B03=5.9.3
set ERL_R15B02=5.9.2
set ERL_R15B01=5.9.1
set ERL_R15B=5.9
set ERL_R14B04=5.8.5
set ERL_R14B03=5.8.4
set ERL_R14B02=5.8.3
set ERL_R14B01=5.8.2
set ERL_R14B=5.8.1
set ERL_R14A=5.8
set ERL_R13B04=5.7.5
set ERL_R13B03=5.7.4
set ERL_R13B02=5.7.3
set ERL_R13B01=5.7.2
set ERL_ALL=%ERL_R17% %ERL_R16B03% %ERL_R16B02% %ERL_R16B01% %ERL_R16B% %ERL_R15B03_1% %ERL_R15B03% %ERL_R15B02% %ERL_R15B01% %ERL_R15B% %ERL_R14B04% %ERL_R14B03% %ERL_R14B02% %ERL_R14B01% %ERL_R14B% %ERL_R14A% %ERL_R13B04% %ERL_R13B03% %ERL_R13B02% %ERL_R13B01%
if not defined ERLANG_HOME (
    FOR %%c in (%ERL_ALL%) DO (
        FOR %%p in ("%ProgramFiles%\erl%%c" "%ProgramFiles(x86)%\erl%%c") DO (
            set FULL_PATH=%%p
            if exist !FULL_PATH! (
                set ERLANG_HOME=%%p
                goto found
            )
        )
    )
)

:found

echo ERLANG_HOME=%ERLANG_HOME%

ENDLOCAL & set ERLANG_HOME=%ERLANG_HOME%

windows: add support for Erlang 17.0 in the batch scripts


@echo off
:: set path to erlang installation

SETLOCAL ENABLEDELAYEDEXPANSION

set ERL_R17_1=6.1
set ERL_R17=6.0
set ERL_R16B03=5.10.4
set ERL_R16B02=5.10.3
set ERL_R16B01=5.10.2
set ERL_R16B=5.10.1
set ERL_R15B03_1=5.9.3.1
set ERL_R15B03=5.9.3
set ERL_R15B02=5.9.2
set ERL_R15B01=5.9.1
set ERL_R15B=5.9
set ERL_R14B04=5.8.5
set ERL_R14B03=5.8.4
set ERL_R14B02=5.8.3
set ERL_R14B01=5.8.2
set ERL_R14B=5.8.1
set ERL_R14A=5.8
set ERL_R13B04=5.7.5
set ERL_R13B03=5.7.4
set ERL_R13B02=5.7.3
set ERL_R13B01=5.7.2
set ERL_ALL=%ERL_R17_1% %ERL_R17% %ERL_R16B03% %ERL_R16B02% %ERL_R16B01% %ERL_R16B% %ERL_R15B03_1% %ERL_R15B03% %ERL_R15B02% %ERL_R15B01% %ERL_R15B% %ERL_R14B04% %ERL_R14B03% %ERL_R14B02% %ERL_R14B01% %ERL_R14B% %ERL_R14A% %ERL_R13B04% %ERL_R13B03% %ERL_R13B02% %ERL_R13B01%
if not defined ERLANG_HOME (
    FOR %%c in (%ERL_ALL%) DO (
        FOR %%p in ("%ProgramFiles%\erl%%c" "%ProgramFiles(x86)%\erl%%c") DO (
            set FULL_PATH=%%p
            if exist !FULL_PATH! (
                set ERLANG_HOME=%%p
                goto found
            )
        )
    )
)

:found

echo ERLANG_HOME=%ERLANG_HOME%

ENDLOCAL & set ERLANG_HOME=%ERLANG_HOME%

@echo off
:: set path to erlang installation

SETLOCAL ENABLEDELAYEDEXPANSION

set ERL_R17_3=6.1
set ERL_R17_1=6.1
set ERL_R17=6.0
set ERL_R16B03=5.10.4
set ERL_R16B02=5.10.3
set ERL_R16B01=5.10.2
set ERL_R16B=5.10.1
set ERL_R15B03_1=5.9.3.1
set ERL_R15B03=5.9.3
set ERL_R15B02=5.9.2
set ERL_R15B01=5.9.1
set ERL_R15B=5.9
set ERL_R14B04=5.8.5
set ERL_R14B03=5.8.4
set ERL_R14B02=5.8.3
set ERL_R14B01=5.8.2
set ERL_R14B=5.8.1
set ERL_R14A=5.8
set ERL_R13B04=5.7.5
set ERL_R13B03=5.7.4
set ERL_R13B02=5.7.3
set ERL_R13B01=5.7.2
set ERL_ALL=%ERL_R17_3% %ERL_R17_1% %ERL_R17% %ERL_R16B03% %ERL_R16B02% %ERL_R16B01% %ERL_R16B% %ERL_R15B03_1% %ERL_R15B03% %ERL_R15B02% %ERL_R15B01% %ERL_R15B% %ERL_R14B04% %ERL_R14B03% %ERL_R14B02% %ERL_R14B01% %ERL_R14B% %ERL_R14A% %ERL_R13B04% %ERL_R13B03% %ERL_R13B02% %ERL_R13B01%
if not defined ERLANG_HOME (
    FOR %%c in (%ERL_ALL%) DO (
        FOR %%p in ("%ProgramFiles%\erl%%c" "%ProgramFiles(x86)%\erl%%c") DO (
            set FULL_PATH=%%p
            if exist !FULL_PATH! (
                set ERLANG_HOME=%%p
                goto found
            )
        )
    )
)

:found

echo ERLANG_HOME=%ERLANG_HOME%

ENDLOCAL & set ERLANG_HOME=%ERLANG_HOME%

windows: add support for Erlang 17.3 in the batch scripts


@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem                                                                         ##
@rem  Groovy JVM Bootstrap for Windowz                                       ##
@rem                                                                         ##
@rem ##########################################################################

@rem
@rem $Revision: 4170 $ $Date: 2006-10-26 12:11:12 +0000 (Thu, 26 Oct 2006) $
@rem

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

set DIRNAME=%~1
shift

set CLASS=%~1
shift

if exist "%USERPROFILE%/.groovy/preinit.bat" call "%USERPROFILE%/.groovy/preinit.bat"

@rem Determine the command interpreter to execute the "CD" later
set COMMAND_COM="cmd.exe"
if exist "%SystemRoot%\system32\cmd.exe" set COMMAND_COM="%SystemRoot%\system32\cmd.exe"
if exist "%SystemRoot%\command.com" set COMMAND_COM="%SystemRoot%\command.com"

@rem Use explicit find.exe to prevent cygwin and others find.exe from being used
set FIND_EXE="find.exe"
if exist "%SystemRoot%\system32\find.exe" set FIND_EXE="%SystemRoot%\system32\find.exe"
if exist "%SystemRoot%\command\find.exe" set FIND_EXE="%SystemRoot%\command\find.exe"

:check_JAVA_HOME
@rem Make sure we have a valid JAVA_HOME
if not "%JAVA_HOME%" == "" goto have_JAVA_HOME

echo.
echo ERROR: Environment variable JAVA_HOME has not been set.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo.
goto end

:have_JAVA_HOME
@rem Validate JAVA_HOME
%COMMAND_COM% /C DIR "%JAVA_HOME%" 2>&1 | %FIND_EXE% /I /C "%JAVA_HOME%" >nul
if not errorlevel 1 goto check_GROOVY_HOME

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

:check_GROOVY_HOME
@rem Define GROOVY_HOME if not set
if "%GROOVY_HOME%" == "" set GROOVY_HOME=%DIRNAME%..

:init
@rem Get command-line arguments, handling Windowz variants
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem remove trailing slash from GRAILS_HOME
if "%GRAILS_HOME:~-1%"=="\" SET GRAILS_HOME=%GRAILS_HOME:~0,-1%

@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set CP=
set GRAILS_OPTIONS=

:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CURR_ARG=%~1
if "%CURR_ARG:~0,2%" == "-D" (
	set GRAILS_OPTIONS=%GRAILS_OPTIONS% %~1=%~2
	shift
	shift
	goto win9xME_args_slurp
) else (
	if "x%~1" == "x-cp" (
		set CP=%~2
		shift
		shift
		goto win9xME_args_slurp
	) else (
		if "x%~1" == "x-classpath" (
			set CP=%~2
			shift
			shift
			goto win9xME_args_slurp
		) else (
			set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
			shift
			goto win9xME_args_slurp
		)
	)
)

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

:execute
@rem Setup the command line
set STARTER_CLASSPATH=%GRAILS_HOME%\lib\groovy-all-1.7.1.jar;%GRAILS_HOME%\dist\grails-bootstrap-1.3.0.BUILD-SNAPSHOT.jar

if exist "%USERPROFILE%/.groovy/init.bat" call "%USERPROFILE%/.groovy/init.bat"

@rem Setting a classpath using the -cp or -classpath option means not to use
@rem the global classpath. Groovy behaves then the same as the java
@rem interpreter

if "x" == "x%CLASSPATH%" goto after_classpath
set CP=%CP%;%CLASSPATH%
:after_classpath

set STARTER_MAIN_CLASS=org.codehaus.groovy.grails.cli.support.GrailsStarter
set STARTER_CONF=%GRAILS_HOME%\conf\groovy-starter.conf

set JAVA_EXE=%JAVA_HOME%\bin\java.exe
set TOOLS_JAR=%JAVA_HOME%\lib\tools.jar

if "%JAVA_OPTS%" == "" set JAVA_OPTS=-Xmx512m -XX:MaxPermSize=96m
set JAVA_OPTS=%JAVA_OPTS% -Dprogram.name="%PROGNAME%"
set JAVA_OPTS=%JAVA_OPTS% -Dgrails.home="%GRAILS_HOME%"
set JAVA_OPTS=%JAVA_OPTS% -Dgrails.version="1.3.0.BUILD-SNAPSHOT"
set JAVA_OPTS=%JAVA_OPTS% -Dbase.dir="."
set JAVA_OPTS=%JAVA_OPTS% -Dtools.jar="%TOOLS_JAR%"
set JAVA_OPTS=%JAVA_OPTS% -Dgroovy.starter.conf="%STARTER_CONF%"

if exist "%USERPROFILE%/.groovy/postinit.bat" call "%USERPROFILE%/.groovy/postinit.bat"

@rem Execute Groovy
CALL "%JAVA_EXE%" %JAVA_OPTS% %GRAILS_OPTIONS% -classpath "%STARTER_CLASSPATH%" %STARTER_MAIN_CLASS% --main %CLASS% --conf "%STARTER_CONF%" --classpath "%CP%" "%CMD_LINE_ARGS%"
:end
@rem End local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" endlocal

@rem Optional pause the batch file
if "%GROOVY_BATCH_PAUSE%" == "on" pause

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem                                                                         ##
@rem  Groovy JVM Bootstrap for Windowz                                       ##
@rem                                                                         ##
@rem ##########################################################################

@rem
@rem $Revision: 4170 $ $Date: 2006-10-26 12:11:12 +0000 (Thu, 26 Oct 2006) $
@rem

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

set DIRNAME=%~1
shift

set CLASS=%~1
shift

if exist "%USERPROFILE%/.groovy/preinit.bat" call "%USERPROFILE%/.groovy/preinit.bat"

@rem Determine the command interpreter to execute the "CD" later
set COMMAND_COM="cmd.exe"
if exist "%SystemRoot%\system32\cmd.exe" set COMMAND_COM="%SystemRoot%\system32\cmd.exe"
if exist "%SystemRoot%\command.com" set COMMAND_COM="%SystemRoot%\command.com"

@rem Use explicit find.exe to prevent cygwin and others find.exe from being used
set FIND_EXE="find.exe"
if exist "%SystemRoot%\system32\find.exe" set FIND_EXE="%SystemRoot%\system32\find.exe"
if exist "%SystemRoot%\command\find.exe" set FIND_EXE="%SystemRoot%\command\find.exe"

:check_JAVA_HOME
@rem Make sure we have a valid JAVA_HOME
if not "%JAVA_HOME%" == "" goto have_JAVA_HOME

echo.
echo ERROR: Environment variable JAVA_HOME has not been set.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo.
goto end

:have_JAVA_HOME
@rem Validate JAVA_HOME
%COMMAND_COM% /C DIR "%JAVA_HOME%" 2>&1 | %FIND_EXE% /I /C "%JAVA_HOME%" >nul
if not errorlevel 1 goto check_GRAILS_HOME

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

:check_GRAILS_HOME
@rem Define GRAILS_HOME if not set
if "%GRAILS_HOME%" == "" set GRAILS_HOME=%DIRNAME%..

:init
@rem Get command-line arguments, handling Windowz variants
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem remove trailing slash from GRAILS_HOME
if "%GRAILS_HOME:~-1%"=="\" SET GRAILS_HOME=%GRAILS_HOME:~0,-1%

@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set CP=
set GRAILS_OPTIONS=

:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CURR_ARG=%~1
if "%CURR_ARG:~0,2%" == "-D" (
	set GRAILS_OPTIONS=%GRAILS_OPTIONS% %~1=%~2
	shift
	shift
	goto win9xME_args_slurp
) else (
	if "x%~1" == "x-cp" (
		set CP=%~2
		shift
		shift
		goto win9xME_args_slurp
	) else (
		if "x%~1" == "x-classpath" (
			set CP=%~2
			shift
			shift
			goto win9xME_args_slurp
		) else (
			set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
			shift
			goto win9xME_args_slurp
		)
	)
)

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

:execute
@rem Setup the command line
set STARTER_CLASSPATH=%GRAILS_HOME%\lib\groovy-all-1.7.1.jar;%GRAILS_HOME%\dist\grails-bootstrap-1.3.0.BUILD-SNAPSHOT.jar

if exist "%USERPROFILE%/.groovy/init.bat" call "%USERPROFILE%/.groovy/init.bat"

@rem Setting a classpath using the -cp or -classpath option means not to use
@rem the global classpath. Groovy behaves then the same as the java
@rem interpreter

if "x" == "x%CLASSPATH%" goto after_classpath
set CP=%CP%;%CLASSPATH%
:after_classpath

set STARTER_MAIN_CLASS=org.codehaus.groovy.grails.cli.support.GrailsStarter
set STARTER_CONF=%GRAILS_HOME%\conf\groovy-starter.conf

set JAVA_EXE=%JAVA_HOME%\bin\java.exe
set TOOLS_JAR=%JAVA_HOME%\lib\tools.jar

if "%JAVA_OPTS%" == "" set JAVA_OPTS=-Xmx512m -XX:MaxPermSize=96m
set JAVA_OPTS=%JAVA_OPTS% -Dprogram.name="%PROGNAME%"
set JAVA_OPTS=%JAVA_OPTS% -Dgrails.home="%GRAILS_HOME%"
set JAVA_OPTS=%JAVA_OPTS% -Dgrails.version="1.3.0.BUILD-SNAPSHOT"
set JAVA_OPTS=%JAVA_OPTS% -Dbase.dir="."
set JAVA_OPTS=%JAVA_OPTS% -Dtools.jar="%TOOLS_JAR%"
set JAVA_OPTS=%JAVA_OPTS% -Dgroovy.starter.conf="%STARTER_CONF%"

if exist "%USERPROFILE%/.groovy/postinit.bat" call "%USERPROFILE%/.groovy/postinit.bat"

@rem Execute Groovy
CALL "%JAVA_EXE%" %JAVA_OPTS% %GRAILS_OPTIONS% -classpath "%STARTER_CLASSPATH%" %STARTER_MAIN_CLASS% --main %CLASS% --conf "%STARTER_CONF%" --classpath "%CP%" "%CMD_LINE_ARGS%"
:end
@rem End local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" endlocal

@rem Optional pause the batch file
if "%GROOVY_BATCH_PAUSE%" == "on" pause

fix for GRAILS-5281 "startGrails.bat fails on windows if no GRAILS_HOME is set"


@echo off
:: Copyright (c) 2012 The Chromium Authors. All rights reserved.
:: Use of this source code is governed by a BSD-style license that can be
:: found in the LICENSE file.
setlocal

:: Shall skip automatic update?
IF "%DEPOT_TOOLS_UPDATE%" == "0" GOTO :CALL_GCLIENT

:: Synchronize the root directory before deferring control back to gclient.py.
call "%~dp0update_depot_tools.bat" %*

:CALL_GCLIENT
:: Ensure that "depot_tools" is somewhere in PATH so this tool can be used
:: standalone, but allow other PATH manipulations to take priority.
set PATH=%PATH%;%~dp0

:: Defer control.
IF "%GCLIENT_PY3%" == "1" (
  :: TODO(1003139): Use vpython3 once vpython3 works on Windows.
  python3 "%~dp0gclient.py" %*
) ELSE (
  python "%~dp0gclient.py" %*
)

@echo off
:: Copyright (c) 2012 The Chromium Authors. All rights reserved.
:: Use of this source code is governed by a BSD-style license that can be
:: found in the LICENSE file.
setlocal

:: Shall skip automatic update?
IF "%DEPOT_TOOLS_UPDATE%" == "0" GOTO :CALL_GCLIENT

:: Synchronize the root directory before deferring control back to gclient.py.
call "%~dp0update_depot_tools.bat" %*

:CALL_GCLIENT
:: Ensure that "depot_tools" is somewhere in PATH so this tool can be used
:: standalone, but allow other PATH manipulations to take priority.
set PATH=%PATH%;%~dp0

:: Defer control.
IF "%GCLIENT_PY3%" == "1" (
  :: TODO(1003139): Use vpython3 once vpython3 works on Windows.
  call python3 "%~dp0gclient.py" %*
) ELSE (
  call python "%~dp0gclient.py" %*
)

Use "call" in gclient.bat to restore title

The title of command prompt windows indicates what command is running.
However it is easy to confuse Windows so that it doesn't clear the
status when a program termintes. Apparently a tail from one batch file
to another is sufficient to do this. This change uses "call" to run
python to avoid this minor glitch, making is so that I can tell when
gclient has completed merely by glancing at the command prompt status
bar.

Change-Id: Ibd310362b8dd78589abc443be1841f0937c791fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2133303
Reviewed-by: Edward Lesmes <d05609f027dc667cc37492b1dc1bdea5d60fa82a@chromium.org>
Commit-Queue: Bruce Dawson <fe9e26f3989304bf7275ed139c57fd059c63d22d@chromium.org>


@echo off

:ARGUMENTS_VALIDATION

if /I "%1" == "/help"   (goto :USAGE)
if /I "%1" == "/h"      (goto :USAGE)
if /I "%1" == "/?"      (goto :USAGE)
goto :ARGUMENTS_OK

:USAGE

echo Build and run a subset of test suites
echo.
echo Usage:
echo.
echo appveyor-build.cmd ^<all^|net40^|portable47^|portable7^|portable78^|portable259^|vs^|cambridge_suite^|qa_suite^|smoke^|smoke_only^>
echo.
echo No arguments default to 'smoke' ( build all profiles, run all unit tests, cambridge Smoke, fsharpqa Smoke)
echo.
echo To specify multiple values, separate strings by comma
echo.
echo The example below run portable47, vs and qa:
echo.
echo appveyor-build.cmd portable47,vs,qa_suite
exit /b 1

:ARGUMENTS_OK

set DO_NET40=0
set DO_PORTABLE47=0
set DO_PORTABLE7=0
set DO_PORTABLE78=0
set DO_PORTABLE259=0
set DO_VS=0
set TEST_NET40=0
set TEST_PORTABLE47=0
set TEST_PORTABLE7=0
set TEST_PORTABLE78=0
set TEST_PORTABLE259=0
set TEST_VS=0
set TEST_CAMBRIDGE_SUITE=0
set CONF_CAMBRIDGE_SUITE=
set TEST_QA_SUITE=0
set CONF_QA_SUITE=

setlocal enableDelayedExpansion
set /a counter=0
for /l %%x in (1 1 9) do (
    set /a counter=!counter!+1
    call :SET_CONFIG %%!counter! "!counter!"
)
setlocal disableDelayedExpansion
echo.
echo.

goto :MAIN

:SET_CONFIG
set BUILD_PROFILE=%~1

if "%BUILD_PROFILE%" == "1" if "%2" == "" (
    set BUILD_PROFILE=smoke
)

if "%2" == "" if not "%BUILD_PROFILE%" == "smoke" goto :EOF

echo Parse argument %BUILD_PROFILE%

if /i '%BUILD_PROFILE%' == 'net40' (
    set DO_NET40=1
    set TEST_NET40=1
)

if /i '%BUILD_PROFILE%' == 'portable47' (
    set DO_PORTABLE47=1
    set TEST_PORTABLE47=1
)

if /i '%BUILD_PROFILE%' == 'portable7' (
    set DO_PORTABLE7=1
    set TEST_PORTABLE7=1
)

if /i '%BUILD_PROFILE%' == 'portable78' (
    set DO_PORTABLE78=1
    set TEST_PORTABLE78=1
)

if /i '%BUILD_PROFILE%' == 'portable259' (
    set DO_PORTABLE259=1
    set TEST_PORTABLE259=1
)

if /i '%BUILD_PROFILE%' == 'vs' (
    set DO_VS=1
    set TEST_VS=1
)

if /i '%BUILD_PROFILE%' == 'cambridge_suite' (
    set DO_NET40=1
    set TEST_CAMBRIDGE_SUITE=1
)

if /i '%BUILD_PROFILE%' == 'qa_suite' (
    set DO_NET40=1
    set TEST_QA_SUITE=1
)

if /i '%BUILD_PROFILE%' == 'all' (
    set DO_NET40=1
    set DO_PORTABLE47=1
    set DO_PORTABLE7=1
    set DO_PORTABLE78=1
    set DO_PORTABLE259=1
    set DO_VS=1
    set TEST_NET40=1
    set TEST_PORTABLE47=1
    set TEST_PORTABLE7=1
    set TEST_PORTABLE78=1
    set TEST_PORTABLE259=1
    set TEST_VS=1
    set TEST_CAMBRIDGE_SUITE=1
    set TEST_QA_SUITE=1
)

if /i '%BUILD_PROFILE%' == 'smoke' (
    set DO_NET40=1
    set DO_PORTABLE47=1
    set DO_PORTABLE7=1
    set DO_PORTABLE78=1
    set DO_PORTABLE259=1
    set DO_VS=1
    set TEST_NET40=1
    set TEST_PORTABLE47=1
    set TEST_PORTABLE7=1
    set TEST_PORTABLE78=1
    set TEST_PORTABLE259=1
    set TEST_VS=1
    set TEST_CAMBRIDGE_SUITE=1
    set CONF_CAMBRIDGE_SUITE=Smoke
    set TEST_QA_SUITE=1
    set CONF_QA_SUITE=Smoke
)

if /i '%BUILD_PROFILE%' == 'smoke_only' (
    set CONF_CAMBRIDGE_SUITE=Smoke
    set CONF_QA_SUITE=Smoke
)
goto :EOF

:MAIN

REM after this point, BUILD_PROFILE variable should not be used, use only DO_* or TEST_*

echo Build/Tests configuration:
echo.
echo DO_NET40=%DO_NET40%
echo DO_PORTABLE47=%DO_PORTABLE47%
echo DO_PORTABLE7=%DO_PORTABLE7%
echo DO_PORTABLE78=%DO_PORTABLE78%
echo DO_PORTABLE259=%DO_PORTABLE259%
echo DO_VS=%DO_VS%
echo.
echo TEST_NET40=%TEST_NET40%
echo TEST_PORTABLE47=%TEST_PORTABLE47%
echo TEST_PORTABLE7=%TEST_PORTABLE7%
echo TEST_PORTABLE78=%TEST_PORTABLE78%
echo TEST_PORTABLE259=%TEST_PORTABLE259%
echo TEST_VS=%TEST_VS%
echo TEST_CAMBRIDGE_SUITE=%TEST_CAMBRIDGE_SUITE%
echo CONF_CAMBRIDGE_SUITE=%CONF_CAMBRIDGE_SUITE%
echo TEST_QA_SUITE=%TEST_QA_SUITE%
echo CONF_QA_SUITE=%CONF_QA_SUITE%
echo.

@echo on

set APPVEYOR_CI=1

:: Check prerequisites
if not '%VisualStudioVersion%' == '' goto vsversionset
if exist "%VS140COMNTOOLS%..\ide\devenv.exe" set VisualStudioVersion=14.0
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\common7\ide\devenv.exe" set VisualStudioVersion=14.0
if exist "%ProgramFiles%\Microsoft Visual Studio 14.0\common7\ide\devenv.exe" set VisualStudioVersion=14.0
if not '%VisualStudioVersion%' == '' goto vsversionset
if exist "%VS120COMNTOOLS%..\ide\devenv.exe" set VisualStudioVersion=12.0
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\common7\ide\devenv.exe" set VisualStudioVersion=12.0
if exist "%ProgramFiles%\Microsoft Visual Studio 12.0\common7\ide\devenv.exe" set VisualStudioVersion=12.0

:vsversionset
if '%VisualStudioVersion%' == '' echo Error: Could not find an installation of Visual Studio && goto :failure

if exist "%ProgramFiles(x86)%\MSBuild\%VisualStudioVersion%\Bin\MSBuild.exe" set _msbuildexe="%ProgramFiles(x86)%\MSBuild\%VisualStudioVersion%\Bin\MSBuild.exe"
if exist "%ProgramFiles%\MSBuild\%VisualStudioVersion%\Bin\MSBuild.exe"      set _msbuildexe="%ProgramFiles%\MSBuild\%VisualStudioVersion%\Bin\MSBuild.exe"
if not exist %_msbuildexe% echo Error: Could not find MSBuild.exe. && goto :failure

:: See <http://www.appveyor.com/docs/environment-variables>
if defined APPVEYOR (
    rem See <http://www.appveyor.com/docs/build-phase>
    if exist "C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" (
	rem HACK HACK HACK
	set _msbuildexe=%_msbuildexe% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
    )
)

set _ngenexe="%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\ngen.exe"
if not exist %_ngenexe% echo Error: Could not find ngen.exe. && goto :failure

.\.nuget\NuGet.exe restore packages.config -PackagesDirectory packages -ConfigFile .nuget\nuget.config
@if ERRORLEVEL 1 echo Error: Nuget restore failed  && goto :failure

:: Build
%_msbuildexe% src\fsharp-proto-build.proj
@if ERRORLEVEL 1 echo Error: compiler proto build failed && goto :failure

%_ngenexe% install Proto\net40\bin\fsc-proto.exe
@if ERRORLEVEL 1 echo Error: NGen of proto failed  && goto :failure

%_msbuildexe% src/fsharp-library-build.proj /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library build failed && goto :failure

%_msbuildexe% src/fsharp-compiler-build.proj /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: compiler build failed && goto :failure

if '%DO_PORTABLE47%' == '1' (
%_msbuildexe% src/fsharp-library-build.proj /p:TargetFramework=portable47 /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library portable47 build failed && goto :failure
)

if '%DO_PORTABLE7%' == '1' (
%_msbuildexe% src/fsharp-library-build.proj /p:TargetFramework=portable7 /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library portable7 build failed && goto :failure
)

if '%DO_PORTABLE78%' == '1' (
%_msbuildexe% src/fsharp-library-build.proj /p:TargetFramework=portable78 /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library portable78 build failed && goto :failure
)

if '%DO_PORTABLE259%' == '' (
%_msbuildexe% src/fsharp-library-build.proj /p:TargetFramework=portable259 /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library portable259 build failed && goto :failure
)

if '%TEST_NET40%' == '1' (
%_msbuildexe% src/fsharp-compiler-unittests-build.proj /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: compiler unittests build failed && goto :failure

%_msbuildexe% src/fsharp-library-unittests-build.proj /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library unittests build failed && goto :failure
)

if '%TEST_PORTABLE47%' == '1' (
%_msbuildexe% src/fsharp-library-unittests-build.proj /p:TargetFramework=portable47 /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library unittests build failed portable47 && goto :failure
)

if '%TEST_PORTABLE7%' == '1' (
%_msbuildexe% src/fsharp-library-unittests-build.proj /p:TargetFramework=portable7 /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library unittests build failed portable7 && goto :failure
)

if '%TEST_PORTABLE78%' == '1' (
%_msbuildexe% src/fsharp-library-unittests-build.proj /p:TargetFramework=portable78 /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library unittests build failed portable78 && goto :failure
)

if '%TEST_PORTABLE259%' == '1' (
%_msbuildexe% src/fsharp-library-unittests-build.proj /p:TargetFramework=portable259 /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library unittests build failed portable259 && goto :failure
)

if '%DO_VS%' == '1' (
%_msbuildexe% vsintegration\fsharp-vsintegration-build.proj /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: VS integration build failed && goto :failure
)

if '%TEST_VS%' == '1' (
%_msbuildexe% vsintegration\fsharp-vsintegration-unittests-build.proj /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: VS integration unit tests build failed && goto :failure
)

@echo on
call src\update.cmd release -ngen
call vsintegration\update-vsintegration.cmd release
pushd tests

@echo on
call BuildTestTools.cmd release
@if ERRORLEVEL 1 echo Error: 'BuildTestTools.cmd release' failed && goto :failure

@echo on
if '%TEST_CAMBRIDGE_SUITE%' == '1' (
set FSHARP_TEST_SUITE_USE_NUNIT_RUNNER=true

%_msbuildexe% fsharp\fsharp.tests.fsproj /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: fsharp cambridge tests for nunit failed && goto :failure

call RunTests.cmd release fsharp %CONF_CAMBRIDGE_SUITE%
@if ERRORLEVEL 1 type testresults\fsharp_failures.log && echo Error: 'RunTests.cmd release fsharp %CONF_CAMBRIDGE_SUITE%' failed && goto :failure
set FSHARP_TEST_SUITE_USE_NUNIT_RUNNER=
)

if '%TEST_QA_SUITE%' == '1' (
call RunTests.cmd release fsharpqa %CONF_QA_SUITE%
@if ERRORLEVEL 1 type testresults\fsharpqa_failures.log && echo Error: 'RunTests.cmd release fsharpqa %CONF_QA_SUITE%' failed && goto :failure
)

if '%TEST_NET40%' == '1' (
call RunTests.cmd release compilerunit
@if ERRORLEVEL 1 echo Error: 'RunTests.cmd release compilerunit' failed && goto :failure

call RunTests.cmd release coreunit
@if ERRORLEVEL 1 echo Error: 'RunTests.cmd release coreunit' failed && goto :failure
)

if '%TEST_PORTABLE47%' == '1' (
call RunTests.cmd release coreunitportable47
@if ERRORLEVEL 1 echo Error: 'RunTests.cmd release coreunitportable47' failed && goto :failure
)

if '%TEST_PORTABLE7%' == '1' (
call RunTests.cmd release coreunitportable7
@if ERRORLEVEL 1 echo Error: 'RunTests.cmd release coreunitportable7' failed && goto :failure
)

if '%TEST_PORTABLE78%' == '1' (
call RunTests.cmd release coreunitportable78
@if ERRORLEVEL 1 echo Error: 'RunTests.cmd release coreunitportable78' failed && goto :failure
)

if '%TEST_PORTABLE259%' == '1' (
call RunTests.cmd release coreunitportable259
@if ERRORLEVEL 1 echo Error: 'RunTests.cmd release coreunitportable259' failed && goto :failure
)

rem tests for TEST_VS are not executed

popd

goto :eof

:failure
exit /b 1

@echo off

:ARGUMENTS_VALIDATION

if /I "%1" == "/help"   (goto :USAGE)
if /I "%1" == "/h"      (goto :USAGE)
if /I "%1" == "/?"      (goto :USAGE)
goto :ARGUMENTS_OK

:USAGE

echo Build and run a subset of test suites
echo.
echo Usage:
echo.
echo appveyor-build.cmd ^<all^|net40^|portable47^|portable7^|portable78^|portable259^|vs^|cambridge_suite^|qa_suite^|smoke^|smoke_only^|build_only^>
echo.
echo No arguments default to 'smoke' ( build all profiles, run all unit tests, cambridge Smoke, fsharpqa Smoke)
echo.
echo To specify multiple values, separate strings by comma
echo.
echo The example below run portable47, vs and qa:
echo.
echo appveyor-build.cmd portable47,vs,qa_suite
exit /b 1

:ARGUMENTS_OK

set DO_NET40=0
set DO_PORTABLE47=0
set DO_PORTABLE7=0
set DO_PORTABLE78=0
set DO_PORTABLE259=0
set DO_VS=0
set TEST_NET40=0
set TEST_PORTABLE47=0
set TEST_PORTABLE7=0
set TEST_PORTABLE78=0
set TEST_PORTABLE259=0
set TEST_VS=0
set TEST_CAMBRIDGE_SUITE=0
set CONF_CAMBRIDGE_SUITE=
set TEST_QA_SUITE=0
set CONF_QA_SUITE=

setlocal enableDelayedExpansion
set /a counter=0
for /l %%x in (1 1 9) do (
    set /a counter=!counter!+1
    call :SET_CONFIG %%!counter! "!counter!"
)
setlocal disableDelayedExpansion
echo.
echo.

goto :MAIN

:SET_CONFIG
set BUILD_PROFILE=%~1

if "%BUILD_PROFILE%" == "1" if "%2" == "" (
    set BUILD_PROFILE=smoke
)

if "%2" == "" if not "%BUILD_PROFILE%" == "smoke" goto :EOF

echo Parse argument %BUILD_PROFILE%

if /i '%BUILD_PROFILE%' == 'net40' (
    set DO_NET40=1
    set TEST_NET40=1
)

if /i '%BUILD_PROFILE%' == 'portable47' (
    set DO_PORTABLE47=1
    set TEST_PORTABLE47=1
)

if /i '%BUILD_PROFILE%' == 'portable7' (
    set DO_PORTABLE7=1
    set TEST_PORTABLE7=1
)

if /i '%BUILD_PROFILE%' == 'portable78' (
    set DO_PORTABLE78=1
    set TEST_PORTABLE78=1
)

if /i '%BUILD_PROFILE%' == 'portable259' (
    set DO_PORTABLE259=1
    set TEST_PORTABLE259=1
)

if /i '%BUILD_PROFILE%' == 'vs' (
    set DO_VS=1
    set TEST_VS=1
)

if /i '%BUILD_PROFILE%' == 'cambridge_suite' (
    set DO_NET40=1
    set TEST_CAMBRIDGE_SUITE=1
)

if /i '%BUILD_PROFILE%' == 'qa_suite' (
    set DO_NET40=1
    set TEST_QA_SUITE=1
)

if /i '%BUILD_PROFILE%' == 'all' (
    set DO_NET40=1
    set DO_PORTABLE47=1
    set DO_PORTABLE7=1
    set DO_PORTABLE78=1
    set DO_PORTABLE259=1
    set DO_VS=1
    set TEST_NET40=1
    set TEST_PORTABLE47=1
    set TEST_PORTABLE7=1
    set TEST_PORTABLE78=1
    set TEST_PORTABLE259=1
    set TEST_VS=1
    set TEST_CAMBRIDGE_SUITE=1
    set TEST_QA_SUITE=1
)

if /i '%BUILD_PROFILE%' == 'smoke' (
    set DO_NET40=1
    set DO_PORTABLE47=1
    set DO_PORTABLE7=1
    set DO_PORTABLE78=1
    set DO_PORTABLE259=1
    set DO_VS=1
    set TEST_NET40=1
    set TEST_PORTABLE47=1
    set TEST_PORTABLE7=1
    set TEST_PORTABLE78=1
    set TEST_PORTABLE259=1
    set TEST_VS=1
    set TEST_CAMBRIDGE_SUITE=1
    set CONF_CAMBRIDGE_SUITE=Smoke
    set TEST_QA_SUITE=1
    set CONF_QA_SUITE=Smoke
)

if /i '%BUILD_PROFILE%' == 'smoke_only' (
    set CONF_CAMBRIDGE_SUITE=Smoke
    set CONF_QA_SUITE=Smoke
)

if /i '%BUILD_PROFILE%' == 'build_only' (
    set TEST_NET40=0
    set TEST_PORTABLE47=0
    set TEST_PORTABLE7=0
    set TEST_PORTABLE78=0
    set TEST_PORTABLE259=0
    set TEST_VS=0
    set TEST_CAMBRIDGE_SUITE=0
    set TEST_QA_SUITE=0
)

goto :EOF

:MAIN

REM after this point, BUILD_PROFILE variable should not be used, use only DO_* or TEST_*

echo Build/Tests configuration:
echo.
echo DO_NET40=%DO_NET40%
echo DO_PORTABLE47=%DO_PORTABLE47%
echo DO_PORTABLE7=%DO_PORTABLE7%
echo DO_PORTABLE78=%DO_PORTABLE78%
echo DO_PORTABLE259=%DO_PORTABLE259%
echo DO_VS=%DO_VS%
echo.
echo TEST_NET40=%TEST_NET40%
echo TEST_PORTABLE47=%TEST_PORTABLE47%
echo TEST_PORTABLE7=%TEST_PORTABLE7%
echo TEST_PORTABLE78=%TEST_PORTABLE78%
echo TEST_PORTABLE259=%TEST_PORTABLE259%
echo TEST_VS=%TEST_VS%
echo TEST_CAMBRIDGE_SUITE=%TEST_CAMBRIDGE_SUITE%
echo CONF_CAMBRIDGE_SUITE=%CONF_CAMBRIDGE_SUITE%
echo TEST_QA_SUITE=%TEST_QA_SUITE%
echo CONF_QA_SUITE=%CONF_QA_SUITE%
echo.

@echo on

set APPVEYOR_CI=1

:: Check prerequisites
if not '%VisualStudioVersion%' == '' goto vsversionset
if exist "%VS140COMNTOOLS%..\ide\devenv.exe" set VisualStudioVersion=14.0
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\common7\ide\devenv.exe" set VisualStudioVersion=14.0
if exist "%ProgramFiles%\Microsoft Visual Studio 14.0\common7\ide\devenv.exe" set VisualStudioVersion=14.0
if not '%VisualStudioVersion%' == '' goto vsversionset
if exist "%VS120COMNTOOLS%..\ide\devenv.exe" set VisualStudioVersion=12.0
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\common7\ide\devenv.exe" set VisualStudioVersion=12.0
if exist "%ProgramFiles%\Microsoft Visual Studio 12.0\common7\ide\devenv.exe" set VisualStudioVersion=12.0

:vsversionset
if '%VisualStudioVersion%' == '' echo Error: Could not find an installation of Visual Studio && goto :failure

if exist "%ProgramFiles(x86)%\MSBuild\%VisualStudioVersion%\Bin\MSBuild.exe" set _msbuildexe="%ProgramFiles(x86)%\MSBuild\%VisualStudioVersion%\Bin\MSBuild.exe"
if exist "%ProgramFiles%\MSBuild\%VisualStudioVersion%\Bin\MSBuild.exe"      set _msbuildexe="%ProgramFiles%\MSBuild\%VisualStudioVersion%\Bin\MSBuild.exe"
if not exist %_msbuildexe% echo Error: Could not find MSBuild.exe. && goto :failure

:: See <http://www.appveyor.com/docs/environment-variables>
if defined APPVEYOR (
    rem See <http://www.appveyor.com/docs/build-phase>
    if exist "C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" (
	rem HACK HACK HACK
	set _msbuildexe=%_msbuildexe% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
    )
)

set _ngenexe="%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\ngen.exe"
if not exist %_ngenexe% echo Error: Could not find ngen.exe. && goto :failure

.\.nuget\NuGet.exe restore packages.config -PackagesDirectory packages -ConfigFile .nuget\nuget.config
@if ERRORLEVEL 1 echo Error: Nuget restore failed  && goto :failure

:: Build
%_msbuildexe% src\fsharp-proto-build.proj
@if ERRORLEVEL 1 echo Error: compiler proto build failed && goto :failure

%_ngenexe% install Proto\net40\bin\fsc-proto.exe
@if ERRORLEVEL 1 echo Error: NGen of proto failed  && goto :failure

%_msbuildexe% src/fsharp-library-build.proj /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library build failed && goto :failure

%_msbuildexe% src/fsharp-compiler-build.proj /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: compiler build failed && goto :failure

if '%DO_PORTABLE47%' == '1' (
%_msbuildexe% src/fsharp-library-build.proj /p:TargetFramework=portable47 /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library portable47 build failed && goto :failure
)

if '%DO_PORTABLE7%' == '1' (
%_msbuildexe% src/fsharp-library-build.proj /p:TargetFramework=portable7 /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library portable7 build failed && goto :failure
)

if '%DO_PORTABLE78%' == '1' (
%_msbuildexe% src/fsharp-library-build.proj /p:TargetFramework=portable78 /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library portable78 build failed && goto :failure
)

if '%DO_PORTABLE259%' == '' (
%_msbuildexe% src/fsharp-library-build.proj /p:TargetFramework=portable259 /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library portable259 build failed && goto :failure
)

if '%TEST_NET40%' == '1' (
%_msbuildexe% src/fsharp-compiler-unittests-build.proj /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: compiler unittests build failed && goto :failure

%_msbuildexe% src/fsharp-library-unittests-build.proj /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library unittests build failed && goto :failure
)

if '%TEST_PORTABLE47%' == '1' (
%_msbuildexe% src/fsharp-library-unittests-build.proj /p:TargetFramework=portable47 /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library unittests build failed portable47 && goto :failure
)

if '%TEST_PORTABLE7%' == '1' (
%_msbuildexe% src/fsharp-library-unittests-build.proj /p:TargetFramework=portable7 /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library unittests build failed portable7 && goto :failure
)

if '%TEST_PORTABLE78%' == '1' (
%_msbuildexe% src/fsharp-library-unittests-build.proj /p:TargetFramework=portable78 /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library unittests build failed portable78 && goto :failure
)

if '%TEST_PORTABLE259%' == '1' (
%_msbuildexe% src/fsharp-library-unittests-build.proj /p:TargetFramework=portable259 /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library unittests build failed portable259 && goto :failure
)

if '%DO_VS%' == '1' (
%_msbuildexe% vsintegration\fsharp-vsintegration-build.proj /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: VS integration build failed && goto :failure
)

if '%TEST_VS%' == '1' (
%_msbuildexe% vsintegration\fsharp-vsintegration-unittests-build.proj /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: VS integration unit tests build failed && goto :failure
)

@echo on
call src\update.cmd release -ngen
call vsintegration\update-vsintegration.cmd release
pushd tests

@echo on
call BuildTestTools.cmd release
@if ERRORLEVEL 1 echo Error: 'BuildTestTools.cmd release' failed && goto :failure

@echo on
if '%TEST_CAMBRIDGE_SUITE%' == '1' (
set FSHARP_TEST_SUITE_USE_NUNIT_RUNNER=true

%_msbuildexe% fsharp\fsharp.tests.fsproj /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: fsharp cambridge tests for nunit failed && goto :failure

call RunTests.cmd release fsharp %CONF_CAMBRIDGE_SUITE%
@if ERRORLEVEL 1 type testresults\fsharp_failures.log && echo Error: 'RunTests.cmd release fsharp %CONF_CAMBRIDGE_SUITE%' failed && goto :failure
set FSHARP_TEST_SUITE_USE_NUNIT_RUNNER=
)

if '%TEST_QA_SUITE%' == '1' (
call RunTests.cmd release fsharpqa %CONF_QA_SUITE%
@if ERRORLEVEL 1 type testresults\fsharpqa_failures.log && echo Error: 'RunTests.cmd release fsharpqa %CONF_QA_SUITE%' failed && goto :failure
)

if '%TEST_NET40%' == '1' (
call RunTests.cmd release compilerunit
@if ERRORLEVEL 1 echo Error: 'RunTests.cmd release compilerunit' failed && goto :failure

call RunTests.cmd release coreunit
@if ERRORLEVEL 1 echo Error: 'RunTests.cmd release coreunit' failed && goto :failure
)

if '%TEST_PORTABLE47%' == '1' (
call RunTests.cmd release coreunitportable47
@if ERRORLEVEL 1 echo Error: 'RunTests.cmd release coreunitportable47' failed && goto :failure
)

if '%TEST_PORTABLE7%' == '1' (
call RunTests.cmd release coreunitportable7
@if ERRORLEVEL 1 echo Error: 'RunTests.cmd release coreunitportable7' failed && goto :failure
)

if '%TEST_PORTABLE78%' == '1' (
call RunTests.cmd release coreunitportable78
@if ERRORLEVEL 1 echo Error: 'RunTests.cmd release coreunitportable78' failed && goto :failure
)

if '%TEST_PORTABLE259%' == '1' (
call RunTests.cmd release coreunitportable259
@if ERRORLEVEL 1 echo Error: 'RunTests.cmd release coreunitportable259' failed && goto :failure
)

rem tests for TEST_VS are not executed

popd

goto :eof

:failure
exit /b 1

add build_only argument at appveyor-build.cmd to skip tests ( others arguments apply )


@rem Builds Google.Protobuf and runs the tests

dotnet build src/Google.Protobuf.sln || goto :error

echo Running tests.

dotnet test -f netcoreapp2.1 src/Google.Protobuf.Test/Google.Protobuf.Test.csproj || goto :error

goto :EOF

:error
echo Failed!
exit /b %errorlevel%

@rem Builds Google.Protobuf and runs the tests

dotnet build src/Google.Protobuf.sln || goto :error

echo Running tests.

dotnet test src/Google.Protobuf.Test/Google.Protobuf.Test.csproj || goto :error

goto :EOF

:error
echo Failed!
exit /b %errorlevel%

test all frameworks on windows

test all frameworks on windows


ECHO off
ECHO MOVE C:\mongo* C:\mongodb
setx MYPATH "%PATH%;C:\mongodb\bin"

ECHO on
FOR /f %%i IN ('dir /ad /b "C:\" ^|findstr /I "mongo"') DO set dest=%%i
ECHO MOVE C:\%dest% C:\mongodb\
setx MYPATH "%PATH%;C:\mongodb\bin"

Revert "Removed for loop and used MOVE command with wildcards"

This reverts commit d4e2e10962b2c4e05b9f54cef8d12e6e4cdff7f2.

I am an idiot and glob commands / wildcards don't work in batch
scripts. Thanks Microsoft.


@echo off
echo Ensuring .NET 4.0 is installed
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://raw.github.com/StefanScherer/arduino-ide/install/InstallNet4.ps1'))"
echo Installing Chocolatey
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin

where cinst
if ERRORLEVEL 1 goto set_chocolatey
goto inst
:set_chocolatey
set ChocolateyInstall=%SystemDrive%\Chocolatey
set PATH=%PATH%;%ChocolateyInstall%\bin
:inst

call cinst vagrant
set PATH=%PATH%;%SystemDrive%\hashicorp\vagrant\bin
cd /D %USERPROFILE%\Documents

call cinst wget
call cinst 7zip
set PATH=%PATH%;C:\Program Files\7-Zip
call cinst vim
where gvim.exe
if ERRORLEVEL 1 call :addVimToUserPath
goto VIM_DONE
:addVimToUserPath
for /F "tokens=2* delims= " %%f IN ('reg query "HKCU\Environment" /v Path ^| findstr /i path') do set OLD_USER_PATH=%%g
reg add HKCU\Environment /v Path /d "%OLD_USER_PATH%;C:\Program Fiels (x86)\vim\vim74" /f
set PATH=%PATH%;C:\Program Files (x86)\vim\vim74
exit /b
:VIM_DONE

call cinst msysgit
set PATH=%PATH%;C:\Program Files (x86)\Git\cmd

call cinst firefox
call cinst flashplayerplugin

set WORKDRIVE=D:

rem Install packer 0.5.1
if not exist %WORKDRIVE%\Packer\cache mkdir %WORKDRIVE%\Packer\cache
setx PACKER_CACHE_DIR %WORKDRIVE%\Packer\cache
set PACKER_CACHE_DIR=%WORKDRIVE%\Packer\cache
if not exist %WORKDRIVE%\Packer\temp mkdir %WORKDRIVE%\Packer\temp
setx PACKER_TEMP_DIR %WORKDRIVE%\Packer\temp
set PACKER_TEMP_DIR=%WORKDRIVE%\Packer\temp

rem call cinst packer
if exist C:\hashicorp\packer\packer.exe goto PACKER_INSTALLED
call wget --no-check-certificate https://dl.bintray.com/mitchellh/packer/0.5.1_windows_amd64.zip -O %TEMP%\0.5.1_windows_amd64.zip
mkdir C:\hashicorp\packer
cd /D C:\hashicorp\packer
7z x %TEMP%\0.5.1_windows_amd64.zip
cd /D %USERPROFILE%
rem :PACKER_INSTALLED
where packer
if ERRORLEVEL 1 call :addPackerToUserPath
goto PACKER_DONE
:addPackerToUserPath
for /F "tokens=2* delims= " %%f IN ('reg query "HKCU\Environment" /v Path ^| findstr /i path') do set OLD_USER_PATH=%%g
reg add HKCU\Environment /v Path /d "%OLD_USER_PATH%;C:\hashicorp\packer" /f
set PATH=%PATH%;C:\hashicorp\packer
exit /b
:PACKER_DONE

rem Install VirtualBox 4.3.6
if not exist "%USERPROFILE%\.VirtualBox\VirtualBox.xml" (
  mkdir "%USERPROFILE%\.VirtualBox"
  call wget --no-check-certificate https://github.com/StefanScherer/basebox-slave/raw/master/VirtualBox.xml -O "%USERPROFILE%\.VirtualBox\VirtualBox.xml"
)
call cinst virtualbox
if not exist %WORKDRIVE%\VirtualBox mkdir %WORKDRIVE%\VirtualBox
rem if exist "C:\program files\oracle\virtualbox\vboxmanage.exe" goto VIRTUALBOX_INSTALLED
rem wget http://download.virtualbox.org/virtualbox/4.3.6/VirtualBox-4.3.6-91406-Win.exe -O %TEMP%\VirtualBox-4.3.6-91406-Win.exe
rem %TEMP%\VirtualBox-4.3.6-91406-Win.exe -s
:VIRTUALBOX_INSTALLED
where vboxmanage
if ERRORLEVEL 1 call :addVirtualBoxToUserPath
goto VIRTUALBOX_DONE
:addVirtualBoxToUserPath
for /F "tokens=2* delims= " %%f IN ('reg query "HKCU\Environment" /v Path ^| findstr /i path') do set OLD_USER_PATH=%%g
reg add HKCU\Environment /v Path /d "%OLD_USER_PATH%;C:\program files\oracle\virtualbox" /f
set PATH=%PATH%;C:\program files\oracle\virtualbox
exit /b
:VIRTUALBOX_DONE

rem Install Jenkins
rem wget http://mirrors.jenkins-ci.org/windows/latest -O %TEMP%\jenkins.zip
rem cd /D %TEMP%
rem unzip jenkins.zip
rem setup.exe -s

if not exist %WORKDRIVE%\GitHub mkdir %WORKDRIVE%\GitHub
cd /D %WORKDRIVE%\GitHub
if not exist basebox-packer (
  git clone https://github.com/StefanScherer/basebox-packer.git
) else (
  cd basebox-packer
  git pull
  cd ..
)

if not exist packer-windows (
  git clone -b san https://github.com/StefanScherer/packer-windows.git
) else (
  cd packer-windows
  git pull
  cd ..
)

if not exist basebox-slave (
  git clone https://github.com/StefanScherer/basebox-slave.git
) else (
  cd basebox-slave
  git pull
  cd ..
)

echo Install VMware PowerCLI...
if not exist "c:\Program Files (x86)\VMware\VMware VIX" (
  if not exist "%TEMP%\VMware-PowerCLI-5.5.0-1295336.exe" (
    call wget -O "%TEMP%\VMware-PowerCLI-5.5.0-1295336.exe" http://roecloudsrv001/vmware/powercli/VMware-PowerCLI-5.5.0-1295336.exe
  )
  powershell -Command "Import-Module ServerManager; Add-WindowsFeature NET-Framework-Features"
  "%TEMP%\VMware-PowerCLI-5.5.0-1295336.exe" /s /v/qn /vADDLOCAL=ALL
  del "%TEMP%\VMware-PowerCLI-5.5.0-1295336.exe"
)

echo Install VMware Workstation...
rem Install VMware Workstation
if not exist "c:\Program Files (x86)\VMware\VMware Workstation" (
  if not exist "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe" (
    call wget -O "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe" http://roecloudsrv001/vmware/workstation10/VMware-workstation-full-10.0.0-1295980.exe
  )
  rem "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe" /s /nsr /v EULAS_AGREED=1 SERIALNUMBER="xxxxx-xxxxx-xxxxx-xxxxx-xxxxx"
  "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe" /s /nsr /v EULAS_AGREED=1
  del "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe"
)

rem put ovftool into path
where ovftool
if ERRORLEVEL 1 call :addOvftoolToUserPath
goto OVFTOOL_DONE
:addOvftoolToUserPath
for /F "tokens=2* delims= " %%f IN ('reg query "HKCU\Environment" /v Path ^| findstr /i path') do set OLD_USER_PATH=%%g
reg add HKCU\Environment /v Path /d "%OLD_USER_PATH%;c:\Program Files (x86)\VMware\VMware Workstation\ovftool" /f
set PATH=%PATH%;c:\Program Files (x86)\VMware\VMware Workstation\ovftool
exit /b
:OVFTOOL_DONE

rem install addtime to measure time
call cinst strawberryperl
set PATH=%PATH%;c:\strawberry\perl\bin
wget --no-check-certificate -O c:\chocolatey\bin\addtime.bat https://github.com/StefanScherer/dotfiles-windows/raw/master/bin/addtime.bat

call cinst javaruntime
if not exist %WORKDRIVE%\jenkins mkdir %WORKDRIVE%\jenkins
if not exist %WORKDRIVE%\swarmclient mkdir %WORKDRIVE%\swarmclient
cd /D %WORKDRIVE%\swarmclient
call wget -O swarm-client.jar http://maven.jenkins-ci.org/content/repositories/releases/org/jenkins-ci/plugins/swarm-client/1.8/swarm-client-1.8-jar-with-dependencies.jar

set jenkinshost=10.115.4.8
net user swarmclient K8934jASD,x9  /ADD
net localgroup Administrators swarmclient /add
rem Due to problems with UDP broadcast, use the -master switch at the moment
rem Schedule start of swarm client at start of the machine (after next reboot)
schtasks /CREATE /SC ONSTART /RU swarmclient /RP K8934jASD,x9 /TN JenkinsSwarmClient /TR "java.exe -jar %WORKDRIVE%\swarmclient\swarm-client.jar -master http://%jenkinshost% -labels packer -fsroot %WORKDRIVE%\jenkins"

cd %WORKDRIVE%\GitHub\packer-windows
vagrant --version
packer --version
vboxmanage --version
ovftool -version

@echo off
echo Ensuring .NET 4.0 is installed
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://raw.github.com/StefanScherer/arduino-ide/install/InstallNet4.ps1'))"
echo Installing Chocolatey
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin

where cinst
if ERRORLEVEL 1 goto set_chocolatey
goto inst
:set_chocolatey
set ChocolateyInstall=%SystemDrive%\Chocolatey
set PATH=%PATH%;%ChocolateyInstall%\bin
:inst

call cinst vagrant
set PATH=%PATH%;%SystemDrive%\hashicorp\vagrant\bin
cd /D %USERPROFILE%\Documents

call cinst wget
call cinst 7zip
set PATH=%PATH%;C:\Program Files\7-Zip
call cinst vim
where gvim.exe
if ERRORLEVEL 1 call :addVimToUserPath
goto VIM_DONE
:addVimToUserPath
for /F "tokens=2* delims= " %%f IN ('reg query "HKCU\Environment" /v Path ^| findstr /i path') do set OLD_USER_PATH=%%g
reg add HKCU\Environment /v Path /d "%OLD_USER_PATH%;C:\Program Fiels (x86)\vim\vim74" /f
set PATH=%PATH%;C:\Program Files (x86)\vim\vim74
exit /b
:VIM_DONE

call cinst msysgit
set PATH=%PATH%;C:\Program Files (x86)\Git\cmd

rem install firefox and all plugins needed to access vCloud via browser
call cinst firefox
call cinst flashplayerplugin
if not exist "%TEMP%\VMware-ClientIntegrationPlugin-5.5.0.exe" (
call wget -O "%TEMP%\VMware-ClientIntegrationPlugin-5.5.0.exe" http://roecloudsrv001/vmware/clientintegrationplugin/VMware-ClientIntegrationPlugin-5.5.0.exe
)
"%TEMP%\VMware-ClientIntegrationPlugin-5.5.0.exe" /s /v/qn
del "%TEMP%\VMware-ClientIntegrationPlugin-5.5.0.exe"

set WORKDRIVE=D:

rem Install packer 0.5.1
if not exist %WORKDRIVE%\Packer\cache mkdir %WORKDRIVE%\Packer\cache
setx PACKER_CACHE_DIR %WORKDRIVE%\Packer\cache
set PACKER_CACHE_DIR=%WORKDRIVE%\Packer\cache
if not exist %WORKDRIVE%\Packer\temp mkdir %WORKDRIVE%\Packer\temp
setx PACKER_TEMP_DIR %WORKDRIVE%\Packer\temp
set PACKER_TEMP_DIR=%WORKDRIVE%\Packer\temp

rem call cinst packer
if exist C:\hashicorp\packer\packer.exe goto PACKER_INSTALLED
call wget --no-check-certificate https://dl.bintray.com/mitchellh/packer/0.5.1_windows_amd64.zip -O %TEMP%\0.5.1_windows_amd64.zip
mkdir C:\hashicorp\packer
cd /D C:\hashicorp\packer
7z x %TEMP%\0.5.1_windows_amd64.zip
cd /D %USERPROFILE%
rem :PACKER_INSTALLED
where packer
if ERRORLEVEL 1 call :addPackerToUserPath
goto PACKER_DONE
:addPackerToUserPath
for /F "tokens=2* delims= " %%f IN ('reg query "HKCU\Environment" /v Path ^| findstr /i path') do set OLD_USER_PATH=%%g
reg add HKCU\Environment /v Path /d "%OLD_USER_PATH%;C:\hashicorp\packer" /f
set PATH=%PATH%;C:\hashicorp\packer
exit /b
:PACKER_DONE

rem Install VirtualBox 4.3.6
if not exist "%USERPROFILE%\.VirtualBox\VirtualBox.xml" (
  mkdir "%USERPROFILE%\.VirtualBox"
  call wget --no-check-certificate https://github.com/StefanScherer/basebox-slave/raw/master/VirtualBox.xml -O "%USERPROFILE%\.VirtualBox\VirtualBox.xml"
)
call cinst virtualbox
if not exist %WORKDRIVE%\VirtualBox mkdir %WORKDRIVE%\VirtualBox
rem if exist "C:\program files\oracle\virtualbox\vboxmanage.exe" goto VIRTUALBOX_INSTALLED
rem wget http://download.virtualbox.org/virtualbox/4.3.6/VirtualBox-4.3.6-91406-Win.exe -O %TEMP%\VirtualBox-4.3.6-91406-Win.exe
rem %TEMP%\VirtualBox-4.3.6-91406-Win.exe -s
:VIRTUALBOX_INSTALLED
where vboxmanage
if ERRORLEVEL 1 call :addVirtualBoxToUserPath
goto VIRTUALBOX_DONE
:addVirtualBoxToUserPath
for /F "tokens=2* delims= " %%f IN ('reg query "HKCU\Environment" /v Path ^| findstr /i path') do set OLD_USER_PATH=%%g
reg add HKCU\Environment /v Path /d "%OLD_USER_PATH%;C:\program files\oracle\virtualbox" /f
set PATH=%PATH%;C:\program files\oracle\virtualbox
exit /b
:VIRTUALBOX_DONE

rem Install Jenkins
rem wget http://mirrors.jenkins-ci.org/windows/latest -O %TEMP%\jenkins.zip
rem cd /D %TEMP%
rem unzip jenkins.zip
rem setup.exe -s

if not exist %WORKDRIVE%\GitHub mkdir %WORKDRIVE%\GitHub
cd /D %WORKDRIVE%\GitHub
if not exist basebox-packer (
  git clone https://github.com/StefanScherer/basebox-packer.git
) else (
  cd basebox-packer
  git pull
  cd ..
)

if not exist packer-windows (
  git clone -b san https://github.com/StefanScherer/packer-windows.git
) else (
  cd packer-windows
  git pull
  cd ..
)

if not exist basebox-slave (
  git clone https://github.com/StefanScherer/basebox-slave.git
) else (
  cd basebox-slave
  git pull
  cd ..
)

echo Install VMware PowerCLI...
if not exist "c:\Program Files (x86)\VMware\VMware VIX" (
  if not exist "%TEMP%\VMware-PowerCLI-5.5.0-1295336.exe" (
    call wget -O "%TEMP%\VMware-PowerCLI-5.5.0-1295336.exe" http://roecloudsrv001/vmware/powercli/VMware-PowerCLI-5.5.0-1295336.exe
  )
  powershell -Command "Import-Module ServerManager; Add-WindowsFeature NET-Framework-Features"
  "%TEMP%\VMware-PowerCLI-5.5.0-1295336.exe" /s /v/qn /vADDLOCAL=ALL
  del "%TEMP%\VMware-PowerCLI-5.5.0-1295336.exe"
)

echo Install VMware Workstation...
rem Install VMware Workstation
if not exist "c:\Program Files (x86)\VMware\VMware Workstation" (
  if not exist "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe" (
    call wget -O "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe" http://roecloudsrv001/vmware/workstation10/VMware-workstation-full-10.0.0-1295980.exe
  )
  rem "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe" /s /nsr /v EULAS_AGREED=1 SERIALNUMBER="xxxxx-xxxxx-xxxxx-xxxxx-xxxxx"
  "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe" /s /nsr /v EULAS_AGREED=1
  del "%TEMP%\VMware-workstation-full-10.0.0-1295980.exe"
)

rem put ovftool into path
where ovftool
if ERRORLEVEL 1 call :addOvftoolToUserPath
goto OVFTOOL_DONE
:addOvftoolToUserPath
for /F "tokens=2* delims= " %%f IN ('reg query "HKCU\Environment" /v Path ^| findstr /i path') do set OLD_USER_PATH=%%g
reg add HKCU\Environment /v Path /d "%OLD_USER_PATH%;c:\Program Files (x86)\VMware\VMware Workstation\ovftool" /f
set PATH=%PATH%;c:\Program Files (x86)\VMware\VMware Workstation\ovftool
exit /b
:OVFTOOL_DONE

rem install addtime to measure time
call cinst strawberryperl
set PATH=%PATH%;c:\strawberry\perl\bin
wget --no-check-certificate -O c:\chocolatey\bin\addtime.bat https://github.com/StefanScherer/dotfiles-windows/raw/master/bin/addtime.bat

call cinst javaruntime
if not exist %WORKDRIVE%\jenkins mkdir %WORKDRIVE%\jenkins
if not exist %WORKDRIVE%\swarmclient mkdir %WORKDRIVE%\swarmclient
cd /D %WORKDRIVE%\swarmclient
call wget -O swarm-client.jar http://maven.jenkins-ci.org/content/repositories/releases/org/jenkins-ci/plugins/swarm-client/1.8/swarm-client-1.8-jar-with-dependencies.jar

set jenkinshost=10.115.4.8
net user swarmclient K8934jASD,x9  /ADD
net localgroup Administrators swarmclient /add
rem Due to problems with UDP broadcast, use the -master switch at the moment
rem Schedule start of swarm client at start of the machine (after next reboot)
schtasks /CREATE /SC ONSTART /RU swarmclient /RP K8934jASD,x9 /TN JenkinsSwarmClient /TR "java.exe -jar %WORKDRIVE%\swarmclient\swarm-client.jar -master http://%jenkinshost% -labels packer -fsroot %WORKDRIVE%\jenkins"

cd %WORKDRIVE%\GitHub\packer-windows
vagrant --version
packer --version
vboxmanage --version
ovftool -version

install vmware plugin for firefox

install vmware plugin for firefox


set PATH=C:\Qt\Qt5.5.1\5.5\mingw492_32\bin;C:\Qt\Qt5.5.1\Tools\mingw492_32\bin;%PATH%
qmake "ring_qt.pro"
mingw32-make
copy release\ringqt.dll ..\..\bin

RingQt: Add buildmingw32.bat to build RingQt using Qt 5.5.1 for Windows


@echo off

echo Building dependencies...

if exist lib (rd lib /q /s)
md lib
cd lib
md Debug
md Release
cd ../
REM ######################################################################################################
echo Building protobuf...

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

cd protobuf/cmake
md build
cd build
cmake -G "Visual Studio 14 Win64" -Dprotobuf_BUILD_SHARED_LIBS=ON -Dprotobuf_BUILD_TESTS=OFF ..
"%VS140COMNTOOLS%..\IDE\Devenv" protobuf.sln /build "Debug|x64"
"%VS140COMNTOOLS%..\IDE\Devenv" protobuf.sln /build "Release|x64"
copy Debug\*.dll ..\..\..\lib\Debug /Y
copy Debug\*.lib ..\..\..\lib\Debug /Y
copy Release\*.dll ..\..\..\lib\Release /Y
copy Release\*.lib ..\..\..\lib\Release /Y
cd ..\..\..\
REM ######################################################################################################
echo Building libevent...

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

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

cd glog
md build
cd build
cmake -G "Visual Studio 14 Win64" ..
"%VS140COMNTOOLS%..\IDE\Devenv" google-glog.sln /build "Debug|x64"
"%VS140COMNTOOLS%..\IDE\Devenv" google-glog.sln /build "Release|x64"
copy Debug\*.lib ..\..\lib\Debug /Y
copy Release\*.lib ..\..\lib\Release /Y
cd ..\..\
REM ######################################################################################################
echo Building evpp...

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

cd evpp
cd vsprojects
"%VS140COMNTOOLS%..\IDE\Devenv" libevpp.sln /build "Debug|x64" /project evpp_static.vcxproj
"%VS140COMNTOOLS%..\IDE\Devenv" libevpp.sln /build "Release|x64" /project evpp_static.vcxproj
cd ..\..\
REM ####################################################################################################
REM back to root dir
cd ../

@echo off

echo Building dependencies...

echo Building evpp...

cd evpp
cd vsprojects
"%VS140COMNTOOLS%..\IDE\Devenv" libevpp.sln /build "Debug|x64" /project libevpp.vcxproj
"%VS140COMNTOOLS%..\IDE\Devenv" libevpp.sln /build "Release|x64" /project libevpp.vcxproj
cd ..\..\
REM ####################################################################################################
REM back to root dir
cd ../

modify evpp build bat

modify evpp build bat

Former-commit-id: 1ea3857ac6ebbcc26e220a820abfb4e60b73cc12 [formerly 99bc0b52cd57ea5dec3c750e36bbe73395b2d506] [formerly 9253de9b3b1ebd6bff1f1a2a73f1fd473c6228b3 [formerly 0f377a50d642d654fc8b66b795f11bf3794df499]]
Former-commit-id: 7a1b59a5459fa569dfc3bd431192f3ea66fd5b57 [formerly fb2c8208582024b46f2cdd88f9722661b8ae4ae1]
Former-commit-id: 6c68bd813675911680f33e5de26f9afbd5824c36
Former-commit-id: f0343dbef219d8d31a50e216816f6c399a19d8f5


echo OFF

set UPLOAD_TARGETS=python-parse python-pkgtk

if "%ANACONDA_USERNAME%" == "" (
  set /p ANACONDA_USERNAME="Username: "
) else (
  echo Username: %ANACONDA_USERNAME%;
)

if "%ANACONDA_PASSWORD%" == "" (
  set /p ANACONDA_USERNAME=%ANACONDA_USERNAME%%"'s password: "
) else (
  echo %ANACONDA_USERNAME%'s password: [secure];
)

set ANACONDA_UPLOAD_FLAGS=-c conda-forge %ANACONDA_UPLOAD_FLAGS%
if "%ANACONDA_CHANNEL%" == "" (
    set ANACONDA_CHANNEL=statiskit
) else (
    echo Using anaconda channel: %ANACONDA_CHANNEL%
    set ANACONDA_UPLOAD_FLAGS=-c statiskit "%ANACONDA_UPLOAD_FLAGS%
)

echo ON

conda install -n root anaconda-client
if %errorlevel% neq 0 (
  exit /b %errorlevel%
)

echo OFF

echo y|anaconda login --username %ANACONDA_USERNAME% --password %ANACONDA_PASSWORD%
if %errorlevel% neq 0 (
  exit /b %errorlevel%
)

echo ON

git clone https://gist.github.com/c491cb08d570beeba2c417826a50a9c3.git toolchain
if %errorlevel% neq 0 (
  anaconda logout
  exit /b %errorlevel%
)
cd toolchain
call config.bat
if %errorlevel% neq 0 (
  cd ..
  anaconda logout
  rmdir toolchain /s /q
  exit /b %errorlevel%
)
cd ..
rmdir toolchain /s /q

for %%x in (%UPLOAD_TARGETS%) do (
  <nul set /p="for /f %%%%i in ('conda build " >> _upload.bat
  <nul set /p=%%x >> _upload.bat
  <nul set /p=" -c " >> _upload.bat
  <nul set /p=%ANACONDA_CHANNEL% >> _upload.bat
  <nul set /p=" " >> _upload.bat
  <nul set /p=%ANACONDA_FLAGS% >> _upload.bat
  <nul set /p=" --output') ( set UPLOAD_FILE=%%%%i )" >> _upload.bat
  echo. >> _upload.bat
  <nul set /p="anaconda upload --user " >> _upload.bat
  <nul set /p=%ANACONDA_CHANNEL% >> _upload.bat
  <nul set /p=" %UPLOAD_FILE%" >> _upload.bat
  echo. >> _upload.bat
  <nul set /p="if \%errorlevel\% neq 0 " >> _upload.bat
  echo upload failed >> _upload.bat
  call _upload.bat
  del _upload.bat
)

anaconda logout

echo OFF

set UPLOAD_TARGETS=python-parse python-pkgtk

if "%ANACONDA_USERNAME%" == "" (
  set /p ANACONDA_USERNAME="Username: "
) else (
  echo Username: %ANACONDA_USERNAME%;
)

if "%ANACONDA_PASSWORD%" == "" (
  set /p ANACONDA_USERNAME=%ANACONDA_USERNAME%%"'s password: "
) else (
  echo %ANACONDA_USERNAME%'s password: [secure];
)

set ANACONDA_UPLOAD_FLAGS=-c conda-forge %ANACONDA_UPLOAD_FLAGS%
if "%ANACONDA_CHANNEL%" == "" (
    set ANACONDA_CHANNEL=statiskit
) else (
    echo Using anaconda channel: %ANACONDA_CHANNEL%
    set ANACONDA_UPLOAD_FLAGS=-c statiskit "%ANACONDA_UPLOAD_FLAGS%
)

echo ON

conda install -n root anaconda-client
if %errorlevel% neq 0 (
  exit /b %errorlevel%
)

echo OFF

echo y|anaconda login --username %ANACONDA_USERNAME% --password %ANACONDA_PASSWORD%
if %errorlevel% neq 0 (
  exit /b %errorlevel%
)

echo ON

git clone https://gist.github.com/c491cb08d570beeba2c417826a50a9c3.git toolchain
if %errorlevel% neq 0 (
  anaconda logout
  exit /b %errorlevel%
)
cd toolchain
call config.bat
if %errorlevel% neq 0 (
  cd ..
  anaconda logout
  rmdir toolchain /s /q
  exit /b %errorlevel%
)
cd ..
rmdir toolchain /s /q

for %%x in (%UPLOAD_TARGETS%) do (
  <nul set /p="for /f %%%%i in ('conda build " >> _upload.bat
  <nul set /p=%%x >> _upload.bat
  <nul set /p=" -c " >> _upload.bat
  <nul set /p=%ANACONDA_CHANNEL% >> _upload.bat
  <nul set /p=" " >> _upload.bat
  <nul set /p=%ANACONDA_FLAGS% >> _upload.bat
  <nul set /p=" --output') ( set UPLOAD_FILE=%%%%i )" >> _upload.bat
  echo. >> _upload.bat
  <nul set /p="anaconda upload --user " >> _upload.bat
  <nul set /p=%ANACONDA_CHANNEL% >> _upload.bat
  <nul set /p=" %UPLOAD_FILE%" >> _upload.bat
  echo. >> _upload.bat
  <nul set /p="if \%errorlevel\% neq 0 " >> _upload.bat
  echo upload failed >> _upload.bat
  more _upload.bat
  del _upload.bat
)

anaconda logout

Update upload.bat

Update upload.bat


::-------------------------------------------------------------------------------------------------------
:: Copyright (C) Microsoft. All rights reserved.
:: Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
::-------------------------------------------------------------------------------------------------------

:: PGO Build Workflow:
:: - pre_pgi.cmd
:: - build (with PGI instrumentation enabled)
:: - post_pgi.cmd
:: - pogo_training.ps1
:: - pre_pgo.cmd
:: - build (using PGO profile)
:: * post_pgo.cmd

@echo off

if "%PogoConfig%"=="False" (
    echo ---- Not a Pogo Config. Skipping step.
    exit /b 0
)

set binpath_pgo=%1

if "%binpath_pgo%"=="" (
  goto:usage
)

set POGO_TYPE=

REM Clean binaries we no longer need
if exist %binpath_pgo%\*.pgc ( del %binpath_pgo%\*.pgc )
if exist %binpath_pgo%\*.pgd ( del %binpath_pgo%\*.pgd )
if exist %binpath_pgo%\pgort* ( del %binpath_pgo%\pgort* )

goto:eof

:usage
  echo Invalid/missing arguments
  echo.
  echo Usage: post_pgo.cmd ^<binary_path^>
  echo   - binary_path: output path of your binaries

exit /b 1

::-------------------------------------------------------------------------------------------------------
:: Copyright (C) Microsoft. All rights reserved.
:: Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
::-------------------------------------------------------------------------------------------------------

:: PGO Build Workflow:
:: - pre_pgi.cmd
:: - build (with PGI instrumentation enabled)
:: - post_pgi.cmd
:: - pogo_training.ps1
:: - pre_pgo.cmd
:: - build (using PGO profile)
:: * post_pgo.cmd

@echo off

if "%PogoConfig%"=="False" (
    echo ---- Not a Pogo Config. Skipping step.
    exit /b 0
)

set binpath_pgo=%1

if "%binpath_pgo%"=="" (
  goto:usage
)

set POGO_TYPE=

REM Clean binaries we no longer need
if exist %binpath_pgo%\*.lib ( del %binpath_pgo%\*.lib )
if exist %binpath_pgo%\*.pgc ( del %binpath_pgo%\*.pgc )
if exist %binpath_pgo%\*.pgd ( del %binpath_pgo%\*.pgd )
if exist %binpath_pgo%\pgort* ( del %binpath_pgo%\pgort* )

goto:eof

:usage
  echo Invalid/missing arguments
  echo.
  echo Usage: post_pgo.cmd ^<binary_path^>
  echo   - binary_path: output path of your binaries

exit /b 1

Remove .lib artifact from pogo build

Remove .lib artifact from pogo build


REM work in progress
REM Setup a non-production BigFix Eval Server with SQL Developer Edition.

REM http://software.bigfix.com/download/bes/95/BigFix-BES-9.5.9.62.exe
REM http://download.microsoft.com/download/2/5/0/2508F7B4-6DDE-4C3E-B1FA-E1EB66F2F79F/SQLServer2016-SSEI-Dev.exe

SET BASEFOLDER=C:\tmp

REM Make folder if not existing:  https://stackoverflow.com/questions/4165387/create-folder-with-batch-but-only-if-it-doesnt-already-exist
if not exist "%BASEFOLDER%" mkdir %BASEFOLDER%

REM Open folder:
start "" %BASEFOLDER%

REM https://github.com/jgstew/bigfix-content/blob/master/fixlet/Install%20SQL%20Server%20Management%20Studio%2016.5.1%20-%20Windows.bes
REM Download SQL Server Management Studio:
start "" powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://download.microsoft.com/download/f/e/b/feb0e6be-21ce-4f98-abee-d74065e32d0a/SSMS-Setup-ENU.exe', '%BASEFOLDER%\SSMS-Setup-ENU.exe') }" -ExecutionPolicy Bypass

REM Download BigFix Root Server:
start "" powershell -command "& { (New-Object Net.WebClient).DownloadFile('http://software.bigfix.com/download/bes/100/BigFix-BES-10.0.0.133.exe', '%BASEFOLDER%\BigFix-BES.exe') }" -ExecutionPolicy Bypass

REM Download BigFix Fixlet Debugger:
REM http://software.bigfix.com/download/bes/100/util/QNA10.0.0.133.zip
start "" powershell -command "& { (New-Object Net.WebClient).DownloadFile('http://software.bigfix.com/download/bes/100/util/QNA10.0.0.133.zip', '%BASEFOLDER%\BigFix-FixletDebugger.zip') }" -ExecutionPolicy Bypass

REM Download SQLServer Developer Edition:
powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://download.microsoft.com/download/5/A/7/5A7065A2-C81C-4A31-9972-8A31AC9388C1/SQLServer2017-SSEI-Dev.exe', '%BASEFOLDER%\SQLServer-SSEI-Dev.exe') }" -ExecutionPolicy Bypass
REM Install SQLServer Developer Edition:
REM https://docs.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server-from-the-command-prompt?view=sql-server-2017
REM Download Commnad:
%BASEFOLDER%\SQLServer-SSEI-Dev.exe /MEDIAPATH="%BASEFOLDER%" /ACTION=Download /LANGUAGE=en-US /MEDIATYPE=CAB /QUIET

REM Install Command: (interactive)
%BASEFOLDER%\SQLServer-SSEI-Dev.exe /ACTION=Install /MEDIAPATH=C:\tmp /IACCEPTSQLSERVERLICENSETERMS /LANGUAGE=en-US

REM https://download.microsoft.com/download/0/5/B/05B2AF8F-906F-4C57-A58E-5780F64F9D62/SSMS-Setup-ENU.exe
REM Install SQL Server Management Studio:
%BASEFOLDER%\SSMS-Setup-ENU.exe /install /quiet /norestart

REM press any key to continue....
pause

REM  TODO: configure SQL SA account?
REM  TODO: configure SQL login from AD account / local win admin account?
REM  TODO: open firewall for MSSQL to local subnet ?
REM  TODO: open firewall for BigFix to local subnet+ ?
REM  TODO: create local MO account
REM  TODO: BES Admin: create BES Admin Password
REM  TODO: BES Admin: set recommended BES Admin Settings
REM  TODO: BES Admin: create encryption keys for client encryption in BES Admin
REM  TODO: BES Admin: schedule BES Property ID Mapper
REM  TODO: configure REST API creds - Web Reports - etc
REM  TODO: create custom site(s) `Shared` `Dashboards` `Private`
REM  TODO: create roles
REM  TODO: enable sites, subscribe computers
REM  TODO: install adobe flash for IE for root or console systems (DISM)
REM  TODO: setup download plugins
REM  TODO:

REM work in progress
REM Setup a non-production BigFix Eval Server with SQL Developer Edition.

REM http://software.bigfix.com/download/bes/95/BigFix-BES-9.5.9.62.exe
REM http://download.microsoft.com/download/2/5/0/2508F7B4-6DDE-4C3E-B1FA-E1EB66F2F79F/SQLServer2016-SSEI-Dev.exe

SET BASEFOLDER=C:\tmp

REM Make folder if not existing:  https://stackoverflow.com/questions/4165387/create-folder-with-batch-but-only-if-it-doesnt-already-exist
if not exist "%BASEFOLDER%" mkdir %BASEFOLDER%

REM Open folder:
start "" %BASEFOLDER%

REM https://github.com/jgstew/bigfix-content/blob/master/fixlet/Install%20SQL%20Server%20Management%20Studio%2016.5.1%20-%20Windows.bes
REM Download SQL Server Management Studio:
start "" powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://download.microsoft.com/download/f/e/b/feb0e6be-21ce-4f98-abee-d74065e32d0a/SSMS-Setup-ENU.exe', '%BASEFOLDER%\SSMS-Setup-ENU.exe') }" -ExecutionPolicy Bypass

REM Download BigFix Root Server:
start "" powershell -command "& { (New-Object Net.WebClient).DownloadFile('http://software.bigfix.com/download/bes/100/BigFix-BES-10.0.0.133.exe', '%BASEFOLDER%\BigFix-BES.exe') }" -ExecutionPolicy Bypass

REM Download BigFix Fixlet Debugger:
REM http://software.bigfix.com/download/bes/100/util/QNA10.0.0.133.zip
start "" powershell -command "& { (New-Object Net.WebClient).DownloadFile('http://software.bigfix.com/download/bes/100/util/QNA10.0.0.133.zip', '%BASEFOLDER%\BigFix-FixletDebugger.zip') }" -ExecutionPolicy Bypass

REM Download SQLServer Developer Edition:
powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://download.microsoft.com/download/5/A/7/5A7065A2-C81C-4A31-9972-8A31AC9388C1/SQLServer2017-SSEI-Dev.exe', '%BASEFOLDER%\SQLServer-SSEI-Dev.exe') }" -ExecutionPolicy Bypass
REM Install SQLServer Developer Edition:
REM https://docs.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server-from-the-command-prompt?view=sql-server-2017
REM Download Commnad:
%BASEFOLDER%\SQLServer-SSEI-Dev.exe /MEDIAPATH="%BASEFOLDER%" /ACTION=Download /LANGUAGE=en-US /MEDIATYPE=CAB /QUIET

REM Install Command: (interactive)
%BASEFOLDER%\SQLServer-SSEI-Dev.exe /ACTION=Install /MEDIAPATH=C:\tmp /IACCEPTSQLSERVERLICENSETERMS /LANGUAGE=en-US

REM https://download.microsoft.com/download/0/5/B/05B2AF8F-906F-4C57-A58E-5780F64F9D62/SSMS-Setup-ENU.exe
REM Install SQL Server Management Studio:
%BASEFOLDER%\SSMS-Setup-ENU.exe /install /quiet /norestart

REM press any key to continue....
pause

REM  TODO: configure SQL SA account?
REM  TODO: configure SQL login from AD account / local win admin account?
REM  TODO: open firewall for MSSQL to local subnet ?
REM  TODO: open firewall for BigFix to local subnet+ ?
REM  TODO: create local MO account
REM  TODO: BES Admin: create BES Admin Password
REM  TODO: BES Admin: set recommended BES Admin Settings
REM  TODO: BES Admin: create encryption keys for client encryption in BES Admin
REM  TODO: BES Admin: schedule BES Property ID Mapper
REM  TODO: configure REST API creds - Web Reports - etc
REM  TODO: create custom site(s) `Shared` `Dashboards` `Private`
REM  TODO: create roles
REM  TODO: enable sites, subscribe computers
REM  TODO: install adobe flash for IE for root or console systems (DISM)
REM  TODO: setup download plugins (enable analyses, deploy Enable Encryption for Clients for root/relays)
REM  TODO:

Update bigfix_setup_root_eval.bat

Update bigfix_setup_root_eval.bat


%WITH_COMPILER% %PYTHON%\Scripts\pip.exe install -r dev_requirements.txt --upgrade --quiet || EXIT 1
%WITH_COMPILER% %PYTHON%\Scripts\py.test.exe --strict --verbose --cov pywincffi --cov-report=xml || EXIT 1
%PYTHON%\Scripts\codecov.exe -f coverage.xml --required || EXIT 1

%WITH_COMPILER% %PYTHON%\Scripts\pip.exe install -r dev_requirements.txt --upgrade --quiet || EXIT 1
%WITH_COMPILER% %PYTHON%\Scripts\py.test.exe --strict --verbose --cov pywincffi --cov-report=xml || EXIT 1
%PYTHON%\Scripts\codecov.exe -X gcov -f coverage.xml --required || EXIT 1

exclude gcov

exclude gcov