Inno Setup CPack generator doesn't support modifiable component installs
The Inno Setup CPack generator added by !8399 (merged) is missing some functionality related to components. The docs are up front about this, mentioning the lack of support for dependencies between components, for example. I'm opening this issue here after discovering that it also doesn't implement the necessary things for a component-based install to be modifiable. I've investigated what it would take, and it seems like a relatively doable change, but for now I want to record the missing pieces in case someone else has the time to assemble them into a proper merge request.
First, here's the official Inno Setup docs, which should be considered the authoritative source: https://jrsoftware.org/ishelp/
The following additional block can be added to the Modules/Internal/CPack/ISScript.template.in
file. It copies the Setup.exe
installer to the install location, and hooks it up to the Windows Add/Remove Programs functionality. I've essentially picked out bits from the setup.iss
script of Inno Setup itself (it's a bit of a gold mine of useful techniques). There are partial fragments of this around the web, but they miss bits, so I've collected the relevant parts together here for easier reference.
[Setup]
AppModifyPath="{app}\Setup.exe" /modify=1
[Files]
Source: "{srcexe}"; DestDir: "{app}"; DestName: "Setup.exe"; Flags: external ignoreversion; Check: not ModifyingCheck
[Code]
var
Modifying: Boolean;
function InitializeSetup(): Boolean;
begin
Modifying := ExpandConstant('{param:modify|0}') = '1';
Result := True;
end;
function ModifyingCheck: Boolean;
begin
Result := Modifying;
end;
The above will give you an installer that supports the "Modify" button in the Add/Remove Programs area. But if you deselect a component that is already installed, you'll get a warning from the installer that the existing component won't be removed. The following two links show how to get the desired behavior (I haven't tried it, but it looks reasonable).
- Removing deselected components when modifying an existing installation: https://stackoverflow.com/questions/52074389/how-to-uninstall-components
- Suppress installer warning about not removing deselected components: https://stackoverflow.com/questions/37631304/inno-setup-suppress-warning-if-other-component-selected
We would probably want to add a switch for projects to state that they want to make a modifiable installer. For installers that don't need it, they don't need to copy the Setup.exe to the install location, and they don't need any of the other logic mentioned above for removing components (the uninstaller just does a blanket removal of everything).