[build.bat] Determine ILRepack folder name dynamically

& improve general consistency and clarity.
This commit is contained in:
Waldi Ravens 2019-05-27 05:11:10 +02:00
parent c5138d9cd6
commit ae4dbaee42
2 changed files with 90 additions and 78 deletions

1
.gitignore vendored
View File

@ -21,6 +21,7 @@
bin/
obj/
SubtitleEdit-*-setup.exe
SubtitleEdit-*.zip
# Visual Studio 2015/2017 cache/options directory
.vs/

141
build.bat
View File

@ -3,15 +3,16 @@ SETLOCAL
CD /D %~dp0
rem Check for the help switches
IF /I "%~1" == "help" GOTO SHOWHELP
IF /I "%~1" == "/help" GOTO SHOWHELP
IF /I "%~1" == "-help" GOTO SHOWHELP
IF /I "%~1" == "--help" GOTO SHOWHELP
IF /I "%~1" == "/?" GOTO SHOWHELP
REM Check for the help switches
IF /I "%~1" == "help" GOTO ShowHelp
IF /I "%~1" == "/help" GOTO ShowHelp
IF /I "%~1" == "-help" GOTO ShowHelp
IF /I "%~1" == "--help" GOTO ShowHelp
IF /I "%~1" == "/?" GOTO ShowHelp
IF /I "%~1" == "-?" GOTO ShowHelp
for /f "usebackq tokens=1* delims=: " %%i in (`vswhere -latest -requires Microsoft.Component.MSBuild`) do (
if /i "%%i"=="installationPath" set InstallDir=%%j
FOR /F "usebackq tokens=1* delims=: " %%A IN (`vswhere -latest -requires Microsoft.Component.MSBuild`) DO (
IF /I "%%A" == "installationPath" SET "VSINSTALLDIR=%%B"
)
IF "%~1" == "" (
@ -30,39 +31,42 @@ IF "%~1" == "" (
IF /I "%~1" == "-Rebuild" SET "BUILDTYPE=Rebuild" & GOTO START
IF /I "%~1" == "--Rebuild" SET "BUILDTYPE=Rebuild" & GOTO START
ECHO. & ECHO Unsupported commandline switch!
ECHO.
ECHO Unsupported commandline switch!
GOTO EndWithError
)
:START
TITLE %BUILDTYPE%ing Subtitle Edit - Release^|Any CPU...
ECHO.
ECHO %BUILDTYPE%ing Subtitle Edit - Release^|Any CPU...
DEL /F /Q SubtitleEdit-*-Setup.exe SubtitleEdit-*.zip 2>NUL
PUSHD "src"
TITLE %BUILDTYPE%ing SubtitleEdit - Release^|Any CPU...
ECHO %InstallDir%
IF exist "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" (
"%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" SubtitleEdit.sln /t:%BUILDTYPE% /p:Configuration=Release /p:Platform="Any CPU"^
/maxcpucount /consoleloggerparameters:DisableMPLogging;Summary;Verbosity=minimal
IF %ERRORLEVEL% NEQ 0 GOTO EndWithError
ECHO.
ECHO Visual Studio installation path: "%VSINSTALLDIR%"
IF EXIST "%VSINSTALLDIR%\MSBuild\15.0\Bin\MSBuild.exe" (
SET "MSBUILD=%VSINSTALLDIR%\MSBuild\15.0\Bin\MSBuild.exe"
) ELSE (
IF exist "%InstallDir%\MSBuild\Current\Bin\MSBuild.exe" (
"%InstallDir%\MSBuild\Current\Bin\MSBuild.exe" SubtitleEdit.sln /t:%BUILDTYPE% /p:Configuration=Release /p:Platform="Any CPU"^
/maxcpucount /consoleloggerparameters:DisableMPLogging;Summary;Verbosity=minimal
IF %ERRORLEVEL% NEQ 0 GOTO EndWithError
) else (
ECHO Cannot find Visual Studio 2017
IF EXIST "%VSINSTALLDIR%\MSBuild\Current\Bin\MSBuild.exe" (
SET "MSBUILD=%VSINSTALLDIR%\MSBuild\Current\Bin\MSBuild.exe"
) ELSE (
ECHO Cannot find Visual Studio 2017.
GOTO EndWithError
)
))
"%MSBUILD%" SubtitleEdit.sln /t:%BUILDTYPE% /p:Configuration=Release /p:Platform="Any CPU"^
/maxcpucount /consoleloggerparameters:DisableMPLogging;Summary;Verbosity=minimal
IF %ERRORLEVEL% NEQ 0 GOTO EndWithError
)
IF /I "%BUILDTYPE%" == "Clean" GOTO END
IF /I "%BUILDTYPE%" == "Clean" GOTO EndSuccessful
ECHO.
ECHO ILRepack...
"packages\ILRepack.2.0.16\tools\ILRepack.exe" /parallel /internalize /targetplatform:v4 /out:"bin\Release\SubtitleEdit.exe" "bin\Release\SubtitleEdit.exe" "bin\Release\libse.dll" "bin\Release\zlib.net.dll" "bin\Release\NHunspell.dll" "DLLs\Interop.QuartzTypeLib.dll"
ECHO.
ECHO Merging assemblies with ILRepack...
FOR /D %%A IN (packages\ILRepack.*) DO (SET "ILREPACKDIR=%%A")
ECHO.
"%ILREPACKDIR%\tools\ILRepack.exe" /parallel /internalize /targetplatform:v4 /out:"bin\Release\SubtitleEdit.exe" "bin\Release\SubtitleEdit.exe"^
"bin\Release\libse.dll" "bin\Release\zlib.net.dll" "bin\Release\NHunspell.dll" "DLLs\Interop.QuartzTypeLib.dll"
IF %ERRORLEVEL% NEQ 0 GOTO EndWithError
POPD
CALL :SubDetectSevenzipPath
@ -72,19 +76,47 @@ IF DEFINED SEVENZIP IF EXIST "%SEVENZIP%" (
)
CALL :SubDetectInnoSetup
IF DEFINED InnoSetupPath (
TITLE Compiling installer...
"%InnoSetupPath%" /O"." /Q "installer\Subtitle_Edit_installer.iss"
IF DEFINED INNOSETUP IF EXIST "%INNOSETUP%" (
TITLE Compiling installer with Inno Setup...
ECHO.
ECHO Compiling installer with Inno Setup...
"%INNOSETUP%" /O"." /Q "installer\Subtitle_Edit_installer.iss"
IF %ERRORLEVEL% NEQ 0 GOTO EndWithError
ECHO. & ECHO Installer compiled successfully!
ECHO.
ECHO Installer compiled successfully!
) ELSE (
ECHO Inno Setup wasn't found; the installer wasn't built
ECHO Inno Setup wasn't found; the installer wasn't built.
)
:EndSuccessful
TITLE %BUILDTYPE%ing Subtitle Edit finished!
GOTO END
:EndWithError
TITLE Compiling Subtitle Edit [ERROR]
ECHO.
ECHO.
ECHO ** ERROR: Build failed and aborted! **
GOTO END
:ShowHelp
TITLE %~nx0 %1
ECHO.
ECHO.
ECHO Usage: %~nx0 [Clean^|Build^|Rebuild]
ECHO.
ECHO Notes: You can also prefix the commands with "-", "--" or "/".
ECHO The arguments are not case sensitive.
ECHO.
ECHO Executing %~nx0 without any arguments is equivalent to "%~nx0 build".
:END
TITLE Compiling Subtitle Edit finished!
ECHO.
ECHO.
ENDLOCAL
PAUSE
@ -92,8 +124,9 @@ EXIT /B
:SubZipFile
TITLE Creating the ZIP file...
ECHO. & ECHO Creating the ZIP file...
TITLE Creating ZIP archive with 7-Zip...
ECHO.
ECHO Creating ZIP archive with 7-Zip...
PUSHD "src\bin\Release"
IF EXIST "temp_zip" RD /S /Q "temp_zip"
IF NOT EXIST "temp_zip" MD "temp_zip"
@ -101,6 +134,7 @@ IF NOT EXIST "temp_zip\Languages" MD "temp_zip\Languages"
IF NOT EXIST "temp_zip\Dictionaries" MD "temp_zip\Dictionaries"
IF NOT EXIST "temp_zip\Ocr" MD "temp_zip\Ocr"
ECHO.
COPY /Y /V "..\..\..\LICENSE.txt" "temp_zip\"
COPY /Y /V "..\..\..\Changelog.txt" "temp_zip\"
COPY /Y /V "Hunspellx86.dll" "temp_zip\"
@ -111,12 +145,12 @@ COPY /Y /V "..\..\..\Dictionaries\*.*" "temp_zip\Dictionaries\"
COPY /Y /V "..\..\..\Ocr\*.*" "temp_zip\Ocr\"
PUSHD "temp_zip"
START "" /B /WAIT "%SEVENZIP%" a -tzip -mx=9 "SE%VERSION%.zip" * >NUL
START "" /B /WAIT "%SEVENZIP%" a -tzip -mx=9 "SubtitleEdit-%VERSION%.zip" * >NUL
IF %ERRORLEVEL% NEQ 0 GOTO EndWithError
ECHO. & ECHO ZIP file created successfully!
MOVE /Y "SE%VERSION%.zip" "..\..\..\.." >NUL
ECHO.
ECHO ZIP archive created successfully!
MOVE /Y "SubtitleEdit-%VERSION%.zip" "..\..\..\.." >NUL
POPD
IF EXIST "temp_zip" RD /S /Q "temp_zip"
POPD
@ -124,29 +158,6 @@ POPD
EXIT /B
:EndWithError
Title Compiling Subtitle Edit [ERROR]
ECHO. & ECHO.
ECHO **ERROR: Build failed and aborted!**
PAUSE
ENDLOCAL
EXIT
:SHOWHELP
TITLE %~nx0 %1
ECHO. & ECHO.
ECHO Usage: %~nx0 [Clean^|Build^|Rebuild]
ECHO.
ECHO Notes: You can also prefix the commands with "-", "--" or "/".
ECHO The arguments are not case sensitive.
ECHO. & ECHO.
ECHO Executing %~nx0 without any arguments is equivalent to "%~nx0 build"
ECHO.
ENDLOCAL
EXIT /B
:SubGetVersion
FOR /F delims^=^"^ tokens^=2 %%A IN ('FINDSTR /R /C:"AssemblyVersion" "src\Properties\AssemblyInfo.cs.template"') DO (
rem 3.4.1.[REVNO]
@ -173,5 +184,5 @@ EXIT /B
:SubDetectInnoSetup
FOR /F "tokens=5*" %%A IN (
'REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1" /v "Inno Setup: App Path" 2^>NUL ^| FIND "REG_SZ" ^|^|
REG QUERY "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1" /v "Inno Setup: App Path" 2^>NUL ^| FIND "REG_SZ"') DO SET "InnoSetupPath=%%B\ISCC.exe"
REG QUERY "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1" /v "Inno Setup: App Path" 2^>NUL ^| FIND "REG_SZ"') DO SET "INNOSETUP=%%B\ISCC.exe"
EXIT /B