build_installer.cmd 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. @echo off
  2. title VCMI Installer Builder
  3. setlocal enabledelayedexpansion
  4. cls
  5. REM Define variables dynamically relative to the normalized base directory
  6. set "AppVersion=1.7.0"
  7. set "AppBuild=1122334455A"
  8. set "InstallerArch=x64compatible"
  9. set "VCMIFolder=VCMI"
  10. set "InstallerName=VCMI-Windows"
  11. REM Override defaults with optional parameters
  12. if not "%~1"=="" set "AppVersion=%~1"
  13. if not "%~2"=="" set "AppBuild=%~2"
  14. if not "%~3"=="" set "InstallerArch=%~3"
  15. if not "%~4"=="" set "VCMIFolder=%~4"
  16. if not "%~5"=="" set "InstallerName=%~5"
  17. if not "%~6"=="" set "SourceFilesPath=%~6"
  18. if not "%~7"=="" set "UCRTFilesPath=%~7"
  19. if not "%InstallerArch%" == "arm64" (
  20. set "AllowedArch=%InstallerArch%compatible"
  21. ) else (
  22. set "AllowedArch=%InstallerArch%"
  23. )
  24. REM Define Inno Setup version
  25. set InnoSetupVer=6
  26. REM Uncomment this line and set custom UCRT source path, otherwise latest installed Windows 10 SDK will be used
  27. REM set "UCRTFilesPath=%ProgFiles%\Windows Kits\10\Redist\10.0.22621.0\ucrt\DLLs"
  28. REM Normally, there is no need to modify anything below this line.
  29. REM Determine the base directory two levels up from the installer location
  30. set "ScriptDir=%~dp0"
  31. set "BaseDir=%ScriptDir%..\..\"
  32. REM Normalize the base directory
  33. for %%i in ("%BaseDir%") do set "BaseDir=%%~fi"
  34. REM Define specific subdirectories relative to the base directory
  35. if not defined SourceFilesPath set "SourceFilesPath=%BaseDir%bin\Release"
  36. set "LangPath=%BaseDir%CI\wininstaller\lang"
  37. set "LicenseFile=%BaseDir%license.txt"
  38. set "IconFile=%BaseDir%clientapp\icons\vcmi.ico"
  39. set "SmallLogo=%BaseDir%CI\wininstaller\vcmismalllogo.bmp"
  40. set "WizardLogo=%BaseDir%CI\wininstaller\vcmilogo.bmp"
  41. set "InstallerScript=%BaseDir%CI\wininstaller\installer.iss"
  42. REM Determine Program Files directory based on system architecture
  43. if exist "%WinDir%\SysWow64" (
  44. set "ProgFiles=%programfiles(x86)%"
  45. ) else (
  46. set "ProgFiles=%programfiles%"
  47. )
  48. set "ISCC=%ProgFiles%\Inno Setup %InnoSetupVer%\ISCC.exe"
  49. REM Github should have it installed in different location
  50. if not exist "%ISCC%" (
  51. set "ISCC=%SystemDrive%\ProgramData\Chocolatey\bin\ISCC.exe"
  52. )
  53. REM Dynamically locate the UCRT path if not defined
  54. if not defined UCRTFilesPath (
  55. set "UCRTBasePath=!ProgFiles!\Windows Kits\10\Redist"
  56. set "UCRTFilesPath="
  57. for /f "delims=" %%d in ('dir /b /ad /on "!UCRTBasePath!"') do (
  58. if exist "!UCRTBasePath!\%%d\ucrt\DLLs" (
  59. set "UCRTFilesPath=!UCRTBasePath!\%%d\ucrt\DLLs"
  60. )
  61. )
  62. )
  63. REM Verify Inno Setup is installed
  64. if not exist "%ISCC%" (
  65. echo.
  66. echo ERROR: Inno Setup !InnoSetupVer! was not found in !ProgFiles!.
  67. echo Please install it or specify the correct path.
  68. echo.
  69. pause
  70. goto :eof
  71. )
  72. REM Verify critical paths
  73. if not exist "%InstallerScript%" (
  74. echo ERROR: Installer script not found: !InstallerScript!
  75. pause
  76. goto :eof
  77. )
  78. if not exist "%SourceFilesPath%" (
  79. echo ERROR: Source files path not found: !SourceFilesPath!
  80. pause
  81. goto :eof
  82. )
  83. if not exist "%UCRTFilesPath%" (
  84. echo ERROR: UCRT files path not found: !UCRTFilesPath!
  85. pause
  86. goto :eof
  87. )
  88. REM Print out installer settings
  89. echo.
  90. echo AppVersion: %AppVersion%
  91. echo AppBuild: %AppBuild%
  92. echo InstallerArch: %InstallerArch%
  93. echo AllowedArch: %AllowedArch%
  94. echo VCMIFolder: %VCMIFolder%
  95. echo InstallerName: %InstallerName%
  96. echo SourceFilesPath: %SourceFilesPath%
  97. echo UCRTFilesPath: %UCRTFilesPath%
  98. echo InstallerScript: %InstallerScript%
  99. echo.
  100. REM Call Inno Setup Compiler
  101. "%ISCC%" "%InstallerScript%" ^
  102. /DAppVersion="%AppVersion%" ^
  103. /DAppBuild="%AppBuild%" ^
  104. /DInstallerArch="%InstallerArch%" ^
  105. /DAllowedArch="%AllowedArch%" ^
  106. /DVCMIFolder="%VCMIFolder%" ^
  107. /DInstallerName="%InstallerName%" ^
  108. /DSourceFilesPath="%SourceFilesPath%" ^
  109. /DUCRTFilesPath="%UCRTFilesPath%" ^
  110. /DLangPath="%LangPath%" ^
  111. /DLicenseFile="%LicenseFile%" ^
  112. /DIconFile="%IconFile%" ^
  113. /DSmallLogo="%SmallLogo%" ^
  114. /DWizardLogo="%WizardLogo%"
  115. goto :eof