Wix find which preconditions are installed after the function selection tree (customizedlg)

I am creating an installer using wix. My installer installs 2 functions.

  • Function 1 depends on Prerequisite-1
  • Feature 2 Depends on Prerequisite-2

As part of the installation, when the user selects Feature 1 from the customizedlg tree and clicks Next, I want to check if the prerequisite for Feature 1 is set. If not, I want to abort the installation.

I can find the necessary condition using RegistrySearch.

How to complete this task?

+4
source share
2 answers

I think that you do not need special actions here, and you should not move the prerequisite check after selecting a function.

Instead, let it go the usual way. Use RegistrySearch to determine if your two prerequisites are set. As a result, you will have two properties - PREREQ1INSTALLED and PREREQ2INSTALLED - set. Make the conditions of your function dependent on these properties, and the user simply will not be able to select the one that is disabled.

If you have only these 2 functions, and at least one of them must be available for installation, set the launch condition to verify that at least one of these prerequisites is installed:

 <Condition>PREREQ1INSTALLED OR PREREQ2INSTALLED</Condition> 
+3
source

To check the precondition after selecting a function, you can use a custom action. In this custom action, you can check whether this function is selected, and according to this, you can use the registry search to get information about the necessary conditions and pre-processing actions.

To get the whole function in a custom action, you can use this code example:

  foreach (FeatureInfo fi in session.Features) { if (fi.RequestState == InstallState.Local || fi.RequestState == InstallState.Source || fi.RequestState == InstallState.Default) { if (fi.Name == "Feature1") { //check for prerequisite for Feature1 } if (fi.Name == "JobService") { //check for prerequisite for Feature2 } } } 

If the precondition is not set, set some session variable to display the message in the user interface

+2
source

All Articles