diff --git a/build_installer.bat b/build_installer.bat index 9c204ccf..9940c110 100644 --- a/build_installer.bat +++ b/build_installer.bat @@ -1,5 +1,14 @@ @echo off -set INNO_ROOT=C:\Program Files (x86)\Inno Setup 5 +REM Use setlocal to automatically unset variables +setlocal + +REM Inno Setup folders. Defined in order of preference. +set INNO6_USER_ROOT=%LOCALAPPDATA%\Programs\Inno Setup 6 +set INNO6_ROOT=%ProgramFiles(x86)%\Inno Setup 6 +SET INNO5_ROOT=%ProgramFiles(x86)%\Inno Setup 5 +set INNO_ROOTS="%INNO6_USER_ROOT%" "%INNO6_ROOT%" "%INNO5_ROOT%" +set INNO_EXE=ISCC.exe +set INNO_EXE_PATH="" set savedir=%cd% cd /d %~dp0 @@ -8,9 +17,25 @@ if not exist build\bin\Release goto buildproject echo Building 64-bit Windows installer... +REM Find where Inno Setup is installed +for %%r in (%INNO_ROOTS%) do ( + if exist "%%~r\%INNO_EXE%" ( + set INNO_EXE_PATH="%%~r\%INNO_EXE%" + goto endcheckinnosetuploop + ) +) +:endcheckinnosetuploop + +REM Check that Inno Setup is installed +if %INNO_EXE_PATH%=="" ( + echo Could not find Inno Setup. + echo Check if Inno Setup is installed. + goto failed +) + cd build\installer-inno if ERRORLEVEL 1 goto buildproject -"%INNO_ROOT%\ISCC.exe" /Qp barrier.iss +%INNO_EXE_PATH% /Qp barrier.iss if ERRORLEVEL 1 goto failed echo Build completed successfully @@ -28,7 +53,4 @@ goto done echo Build failed :done -set INNO_ROOT= - cd /d %savedir% -set savedir=