cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mmccue
Level 4

Feature Conditions

I have 3 features in my project, and through a couple custom dialogs, I prompt the user for some info to determine which of the 3 feature(s) I want to install. I store the results of the dialog in some variables, like INS_FEAT_ONE, INS_FEAT_TWO, INS_FEAT_THREE. I set them to 1 or 0 depending on what happens on those custom dialogs.

I set conditions on my features to raise the INSTALLLEVEL of the feature for the condition, so for feature 1 I would have

Level 110 if INS_FEAT_ONE <> 1

And the same for feature 2 and feature 3.

However, when I run the install, none of the features get installed, and I am not having any luck figuring out why. I thought originally it would be that the feature conditions are evaluated in the execute sequence, so I made sure I put my INS_FEAT_* variables into the SecureCustomProperties property to ensure the values transfer between sequences, but still no go. Other features that do not rely on the conditions get installed, but not the conditional ones.

Any help would be appreciated,
Mike
Labels (1)
0 Kudos
(7) Replies
MichaelU
Level 12 Flexeran
Level 12 Flexeran

What is the base install level for those features, and what is the INSTALLLEVEL of the product? I suspect you may have the level change backwards, as feature install levels higher than INSTALLLEVEL are generally not installed.
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

Feature conditions are evaluated by the standard Windows Installer CostFinalize action. This action runs prior to any dialogs being displayed and initializes things like feature and component states while evaluating conditions. After CostFinalize has run, feature conditions are never reevaluated. As such, by the time any dialogs are displayed, changing property values that are used by the feature conditions will have no effect on what features are selected for installation.

There are a few things you can try to work around this behavior:
- Use the information in the following KB to progressively include additional features to be installed:
HOWTO: Implementing Setup Types in a Basic MSI project

- Use AddLocal/Remove control events conditioned on your properties to include or exclude features to be installed.

- Use a custom action and the MsiSetFeatureState API to programmatically request the state of a feature.
0 Kudos
mmccue
Level 4

Thanks for the replies.

I noticed in the KB article that it talks about moving the CostFinalize action below the InstallWelcome panel. What would be the harm in moving CostFinalize to just before the SetupResume panel? That would do it if at that point the Features are selected, right?
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

Using Method 2 from the article will break the SelectionTree control (which is used on the CustomSetup dialog). Also, moving CostFinalize seems to break the costing process on MSI 4.0 (Vista), which, if I remember correctly, results in runtime errors.

Method 1 was added to the article after it was created and is now the preferred method of implementing setup types. The second method was kept for reference purposes.
0 Kudos
mmccue
Level 4

Yeah, I tried moving the Costing action down and it didn't create the expected results. (Nothing got installed)

I'm not sure I can use Method 1, given the three features are not "stacked" (for lack of a better word) on one another. I have three features, A, B, and C. They can be installed in the following configs:

A
A + C
B
B + C
C

Any suggestions?
0 Kudos
mmccue
Level 4

And to answer your question, MichaelU, I have the InstallLevel of the project set at 100, and the initial install levels of the features set to 1. In the Condition property of the Features I was checking to see if the property I'm using to determine what to install is set, and if not, raising the InstallLevel of the Feature to 110 so it wouldn't get installed.

Also, I tried using the "Remove" event to not install the items I didn't want installed, and that works *great* for installing only the selected features, however, the uninstall then stops removing the files. I have a fourth Feature, that always gets installed, and those will be the only files removed during the uninstall process.
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

The AddLocal/Remove control events would be the simplest for your scenario. We've had other customer's use these without any adverse side effects during install or uninstall. Can you provide a little more detail on how you set up the Remove events and possibly post logs of the install/uninstall?
0 Kudos