7

Is there any way to force a particular feature to be installed if another feature is selected in the feature selection tree? That is without having the features be children of their dependencies?

DeCaf
  • 6,026
  • 1
  • 29
  • 51

1 Answers1

2

Yes this should be possible, if you use the Condition element under a Feature element, you can control the feature install level from a condition.

    <Feature Id="MyDependentFeature">
      <Condition Level="1">(NOT INSTALLED AND &MyMasterFeature=3) OR (INSTALLED AND !MyMasterFeature=3)</Condition> 
    </Feature>

    <Feature Id="MyMasterFeature"> 
    </Feature>

A couple things to explain here:

  • Condition Level="1" tells Wix to set the parent Feature install level to 1 (Install) (Info)
  • (NOT INSTALLED AND &MyMasterFeature=3) If the product is not already installed, and the requested action of MyMasterFeature is Install
  • (INSTALLED AND !MyMasterFeature=3) If the product is already installed, and the install state of MyMasterFeature is Installed. (Info)
abbottdev
  • 807
  • 1
  • 8
  • 13
  • 1
    This will not work because the feature states are not initialized at the moment the conditions are evaluated. – ezolotko Jan 23 '17 at 14:18