I have an WIX installation with a feature and two subfeatures. I would like the feature to be required and the two subfeatures optional but not to install by default. Here is my feature tree:
<Feature Id="A" Level="3" AllowAdvertise="no" TypicalDefault="install"
InstallDefault="local" Absent="disallow" >
<Feature Id="A1" Level="1" AllowAdvertise="no" />
<Feature Id="A2" Level="1" AllowAdvertise="no" />
</Feature>
I thought that adding:
<Property Id="INSTALLLEVEL" Value=3 />
would set the main feature to install and the subfeatures to not install. That isn't the case; all features are installed by default.
I'm using the WixUI_FeatureTree. I wonder if that might be messing up the INSTALLLEVEL property.
So is what I am attempting even possible? How can I disable the two subfeatures by default?
Edit: Interesting. I set INSTALLLEVEL=1000
and tried it again and all features were still set to install. Could WixUI_FeatureTree be clobbering INSTALLLEVEL
?
I think your problem is in overwriting the value of INSTALLLEVEL property duting execution of the UISequence. Adding code
<Property Id="INSTALLLEVEL" Value=3 />
initializes property value on the very beginning of installation process. But when you are moving from dialog to dialog the INSTALLLEVEL property may change before you are seeing the FeathreTree dialog. Please verify verbose log entries of "Propery value changed" and the final value of INSTALLLEVEL property in the end of the log file.
You may need to create custom action to set INSTALLLEVEL to whatever value you need.
Example can be found in WIX sources: SetupType dialog does exactly this:
<Control Id="TypicalButton" Type="PushButton" X="40" Y="65" Width="80"
Height="17" ToolTip="!(loc.SetupTypeDlgTypicalButtonTooltip)"
Default="yes" Text="!(loc.SetupTypeDlgTypicalButton)">
<Publish Property="WixUI_InstallMode" Value="InstallTypical">1</Publish>
<Publish Event="SetInstallLevel" Value="3">1</Publish>
</Control>
The INSTALLLEVEL property is like a high water mark. If you set it to 1000 and you don't want a feature selected by default you have to set the level of the feature to 1001 or higher. It's everything at or below the level that gets installed by default.
From MSDN:
The INSTALLLEVEL property is the initial level at which features are
selected "ON" for installation by default. A feature is installed only
if the value in the Level field of the Feature table is less than or
equal to the current INSTALLLEVEL value. The installation level for
any installation is specified by the INSTALLLEVEL property, and can be
an integral from 1 to 32,767. For further discussion of installation
levels, see Feature Table.
One more observation and probably more important.
Your sub-features have Level="1" and that will install them anyway for any valid INSTALLLEVEL. You should set their level to something higher if you need to disable them by default. Like this:
<Feature Id="A" Level="3" AllowAdvertise="no" TypicalDefault="install"
InstallDefault="local" Absent="disallow" >
<Feature Id="A1" Level="10" AllowAdvertise="no" />
<Feature Id="A2" Level="10" AllowAdvertise="no" />
</Feature>