通过批处理文件(.bat)编译Inno Setup项目

时间:2018-09-18 17:27:22

标签: batch-file inno-setup

在我的工作项目中,我们必须使用Inno Setup创建4个安装程序。这样,我必须逐个文件地运行,最终需要更多的时间。

文件* .iss:

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

是否可以创建一个批处理文件(.bat)来一次编译所有这些* .iss文件?

3 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

如果您正在使用 Visual Studio 开发应用程序,则可以使用 Visual&Installer 扩展程序(https://marketplace.visualstudio.com/items?itemName=unSignedsro.VisualInstaller)并从单个解决方案构建所有安装程序。

此扩展名允许您在Visual Studio中创建常规的Inno Setup项目(具有单个或多个.iss脚本文件),并且可以对它们执行所有Visual Studio操作(例如构建顺序,依赖项等)。

它比命令行更加用户友好,并且可以与任何持续交付/集成系统一起使用。附注:我是此扩展程序的开发人员。

答案 2 :(得分:0)

我为许多已签名的应用程序构建了复杂的版本,因此我创建了一对批处理文件来处理它-第一个(MAKEALL.BAT)包含应用程序列表并调用第二个批处理文件(MAKE.BAT)起作用了。


@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.

运行MAKEALL.BAT将提示输入证书密码,然后使用每个应用程序名称调用MAKE.BAT。 MAKE.BAT有点复杂,因为每个应用程序都需要一个或两个以上的设置来处理内部配置,因此,如果存在其他文件,则将构建这些设置,然后构建并签名应用程序。将另一个应用程序添加到构建中,您要做的就是在MAKEALL.BAT文件中添加一行。 请注意,这假设您使用的是Inno Setup 5,它将需要进行修改才能使用6,并且尚未通过6进行检查。