Archive: How to forbid installation of shared data if no optional sections was selected?


How to forbid installation of shared data if no optional sections was selected?
I have two applications which should be distributed together, but end-user can wish only one of them (or both at the same time). Both applications use the same set of additional files and registry keys (shared data).

So I did something like that:

page components
Section "- shared"
SetOutPath $instdir\data
SectionEnd
Section "Client A"
SetOutPath $instdir\ClientA
SectionEnd
Section "Client B"
SetOutPath $instdir\ClientB
SectionEnd

Data from section "- shared" should be installed for both clients, but if user uncheck both clients on components page, NSIS still will install "- shared" section.
How to forbid it? Or how to force user to check at least one of the clients?

As always there are several ways to manage it. For instance one could be by checking the included example one-section.nsi or by using the .onSelChange callback to verify whether at least one optional section is selected. In case where both sections are unchecked you may disable the next button or popup a message warning.