Compile Inno Setup installer for specific component only

大城市里の小女人 提交于 2020-04-11 08:28:51

问题


I have an Inno Setup script that creates an installer (FullInstall.exe, for example). The script contains several components, selected using types in the standard way, so that it currently has something like:

[Types]
Name: standard; Description: Standard installation
Name: dev; Description: Development installation
Name: disponly; Description: Display utility only
Name: custom; Description: Custom installation; Flags: iscustom

[Components]
Name: core; Description: Core files; Types: standard dev display custom; Flags: fixed
Name: exec; Description: Executive; Types: standard dev custom
Name: exec\debug; Description: Debugger; Types: dev custom
Name: display; Description: Display utility; Types: dev disponly custom

What I've been asked to do is to create an installer for the display utility only. I could create a batch file (DispInstall.bat) which just contained:

FullInstall /COMPONENTS="core,display"

However, this method requires a copy of FullInstall.exe in the same directory as DispInstall.bat, which isn't ideal. Is there a method of creating a DispInstall.exe file which behaves like FullInstall.exe with the disponly type selected, and without the user being able to change the type or component selection?


回答1:


You can use Inno Setup preprocessor to filter the .iss script to a desired subset only:

[Types]
#ifndef disponly
Name: standard; Description: Standard installation
Name: dev; Description: Development installation
#endif
Name: disponly; Description: Display utility only
#ifndef disponly
Name: custom; Description: Custom installation; Flags: iscustom
#endif

[Components]
#ifndef disponly
Name: core; Description: Core files; Types: standard dev display custom; Flags: fixed
Name: exec; Description: Executive; Types: standard dev custom
Name: exec\debug; Description: Debugger; Types: dev custom
#endif
Name: display; Description: Display utility; Types: dev disponly custom

And filter everything else that refers to the filtered types and components, the same way.


And then run Inno Setup compiler with /Ddisponly command-line switch to compile the subset version.


Or if you use Inno Setup GUI for the compilation, you can create disponly.iss like:

#define disponly
#include "FullInstall.iss"


来源:https://stackoverflow.com/questions/48500040/compile-inno-setup-installer-for-specific-component-only

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