Compile Inno Setup project through a batch file (.bat)

╄→гoц情女王★ 提交于 2021-02-08 05:11:40

问题


In my work project, we have to create 4 installers using Inno Setup. That way, I have to run file by file, which ends up demanding more of my time.

Files *.iss:

  • setup_prog_01.iss;
  • setup_prog_02.iss;
  • setup_prog_03.iss;
  • setup_prog_04.iss;

Would it be possible to create a batch file (.bat) to compile all these *.iss files at once?


回答1:


There's ISCC.exe command-line Inno Setup compiler.

So you can do:

ISCC.exe setup_prog_01.iss
ISCC.exe setup_prog_02.iss
ISCC.exe setup_prog_03.iss
ISCC.exe setup_prog_04.iss



回答2:


If you are developing apps using Visual Studio you can use Visual & Installer extension (https://marketplace.visualstudio.com/items?itemName=unSignedsro.VisualInstaller) and build all installers from single solution.

This extension allows you to create regular Inno Setup projects (with single or multiple .iss script file(s)) in Visual Studio and you can perform all Visual Studio actions on them (like Build order, Dependencies etc).

It is much more user friendly than command line and it works with any Continuous Delivery/Integration system. P.S.: I am developer of this extension.




回答3:


I have a complex build for a lot of signed applications so I created a pair of batch files to handle it – the first one (MAKEALL.BAT) contains the list of applications and calls the second batch file (MAKE.BAT) which does the work.


@echo off
echo MAKEALL.BAT - Building all the installation packages.
echo.   
:: Start a new log file
echo Running makeall.cmd > makeall.log
set pass=""
set failed=""
:: prompt for signing password
set /P pass=Enter the certificate password: 
:: call make.cmd to build each package
call make.cmd app01
call make.cmd app02
call make.cmd app03
call make.cmd app04
call make.cmd app05
:: clean up and exit
set pass=""
if NOT "%failed%"=="TRUE" (
  del makeall.LOG
  echo Installation build completed.
  ) ELSE (
  echo Installations encountered some errors.
  )
pause
exit

:: Run MAKE.BAT - INNO SETUP command line compiler using name passed from MAKEALL.CMD
:: Usage: "CALL make.cmd <installation>" which will will prompt for the certificate
:: password and store it in the variable %pass%.
setlocal enableDelayedExpansion
echo.
echo Building the %1 installation
:: Build the local strings needed
set "prog=C:\Program Files"
set "inno=\Inno Setup 5\ISCC.exe"
set "ksign=\kSign\ksigncmd.exe"
set bits=
if exist "%SYSTEMDRIVE%\Program Files (x86)\" set "bits= (x86)"
::
set "iscc=%prog%%bits%%inno%"
set "sign=%prog%%bits%%ksign%"
set "time=http://timestamp.verisign.com/scripts/timstamp.dll"
::
:: Prompt for the certificate password if needed
if "%pass%" == "" set /P pass=Enter the certificate password: 
::
set signing=%sign% /f %cd%\certificate.pfx /p %pass% /t %time% $p
echo Building the %1 installation >> makeall.log
:REBUILD1
:: Build the registration file (app_reg.iss) if it exists
if exist %1_reg.iss "%iscc%" %1_reg.iss >> makeall.log
if %errorlevel% neq 0 (
  set failed=TRUE
  echo Phase 1 ERROR - retrying ...
  GOTO REBUILD1
  )
:REBUILD2
:: Build the user configuration file (app_icn.iss) if it exists
if exist %1_icn.iss "%iscc%" %1_icn.iss >> makeall.log
if %errorlevel% neq 0 (
  set failed=TRUE
  echo Phase 1 ERROR - retrying ...
  GOTO REBUILD2
  )  
:REBUILD3
:: Delay to allow cloud to sync the registration image that we just built.
ping 127.0.0.1 -n 10 > nul
:: Build and sign the main executable
if exist %1_setup.iss "%iscc%" /skSign="%signing%" %1_setup.iss >> makeall.log
if %errorlevel% neq 0 (
  set failed=TRUE
  echo Phase 2 ERROR - retrying ...
  GOTO REBUILD3
  )
echo ... build completed.
echo.

Running MAKEALL.BAT will prompt for the certificate password and then call MAKE.BAT with each of the application names. MAKE.BAT is a little complex because each application needs one or two more setups to handle internal configurations so these are built if the additional files exist and then the application is built and signed. All you have to do to add another application to the build is add one line to the MAKEALL.BAT file. Note that this assumes that you are using Inno Setup 5, it will need an edit to work with 6 and hasn't been checked with 6 yet.



来源:https://stackoverflow.com/questions/52391796/compile-inno-setup-project-through-a-batch-file-bat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!