I have three features in a Selection Tree control. I would like Feature 2 and 3 to be independently selected and installed but if Feature 1 is selected to be installed I want Feature 2 to be automatically selected since Feature 1 depends on it. When my Selection Tree is displayed I see:
[-] All Features
[x] Feature 1 (requires Feature 2)
[x] Feature 2
[x] Feature 3
Where [-] represents the icon for "Will be installed on local hard drive" and [x] represents the icon for "Entire feature will be unavailable".
When I select Feature 1 to be installed I see:
[-] All Features
[-] Feature 1 (requires Feature 2)
[x] Feature 2
[x] Feature 3
But when I select Feature 1, I want Feature 2 to be selected automatically so it would look like this:
[-] All Features
[-] Feature 1 (requires Feature 2)
[-] Feature 2
[x] Feature 3
I don't want Feature 3 to be automatically selected since it is not required by Feature 1. Is there a way to do this? This seems like a simple problem but I could not find any documentation or examples on how to do this. I have tried to use a condition within Feature2 like the following but the condition never gets tested since only Feature 1 was selected:
<Feature Id="ProductFeature" Title="All Features" Display="expand" Level="1">
<Feature Id="Feature1" ConfigurableDirectory="APPLICATIONFOLDER"
Title="Feature 1 (requires Feature 2)" Level="2">
<ComponentRef Id="file1.txt" />
</Feature>
<Feature Id="Feature2" ConfigurableDirectory="APPLICATIONFOLDER"
Title="Feature 2" Level="2">
<ComponentRef Id="file2.txt" />
<Condition Level="1">MsiSelectionTreeSelectedFeature="Feature1"</Condition>
</Feature>
<Feature Id="Feature3" ConfigurableDirectory="APPLICATIONFOLDER"
Title="Feature 3" Level="2">
<ComponentRef Id="file3.txt" />
</Feature>
</Feature>
If only Feature 1 is selected, is there a way to "tell it" to set the Level attribute of Feature2 to 1 so that Feature 2 in the Selection Tree displays the icon showing it will be installed also? If trying to set the Level attribute of Feature2 is not the right approach, is there another method I can use to accomplish the behavior I desire?
Here is my full program if you want to try it:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="41788c15-290e-426f-934e-e5b3bf875013" Name="WixUI_FeatureTree"
Language="1033" Version="1.0.0.0" Manufacturer="WixUI_FeatureTree"
UpgradeCode="5f5d4f80-96f5-4060-a718-539b547d8a29">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<?define FeatureTree=1?>
<UIRef Id="MyWixUI_FeatureTree" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="APPLICATIONFOLDER" Name="WixUI_FeatureTree">
</Directory>
</Directory>
</Directory>
<DirectoryRef Id="APPLICATIONFOLDER">
<Component Id="file1.txt" Guid="FEBD6C0C-1BDF-413C-B7B1-A4E18AC7A6FA">
<File Id="file1.txt" Source="file1.txt" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="file2.txt" Guid="FEBD6C0C-1BDF-413C-B7B1-A4E18AC7A6FB">
<File Id="file2.txt" Source="file2.txt" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="file3.txt" Guid="FEBD6C0C-1BDF-413C-B7B1-A4E18AC7A6FC">
<File Id="file3.txt" Source="file3.txt" KeyPath="yes" Checksum="yes"/>
</Component>
</DirectoryRef>
<Feature Id="ProductFeature" Title="All Features" Display="expand" Level="1">
<Feature Id="Feature1" ConfigurableDirectory="APPLICATIONFOLDER"
Title="Feature 1 (requires Feature 2)" Level="2">
<ComponentRef Id="file1.txt" />
</Feature>
<Feature Id="Feature2" ConfigurableDirectory="APPLICATIONFOLDER"
Title="Feature 2" Level="2">
<ComponentRef Id="file2.txt" />
<Condition Level="1">MsiSelectionTreeSelectedFeature="Feature1"</Condition>
</Feature>
<Feature Id="Feature3" ConfigurableDirectory="APPLICATIONFOLDER"
Title="Feature 3" Level="2">
<ComponentRef Id="file3.txt" />
</Feature>
</Feature>
</Product>
</Wix>