I have a registry key that can be equal to one of two values: special value or null. And two features.
When my registry key equals to special value the installer has to install first feature. if registry key is not found by registry search the installer has to install second feature. And if registry key has null value the installer must not install any of these two features.
What I'm doing or understanding wrong? If INSTALLLEVEL=5, SPECIALVALUE="special",MYTREAT="1" the first feature must be installed,but the installer doesn't install both of the features in this case.
<Feature Id="MyFeatures" Level="1" ConfigurableDirectory='INSTALLLOCATION' Display='expand' AllowAdvertise='no'>
<ComponentRef Id='Empty'/>
<Feature Id='First' Level='3' AllowAdvertise='no' ConfigurableDirectory='INSTALLLOCATION'>
<Condition Level="0">INSTALLLEVEL=4 OR (MYTREAT="1" AND NOT SPECIALVALUE AND NOT SPECIALVALUE="")</Condition>
<Condition Level="1">SPECIALVALUE="special" AND MYTREAT="1"</Condition>
<ComponentRef Id="first_comp"/>
</Feature>
<Feature Id="Second" Level="4" AllowAdvertise="no" ConfigurableDirectory="INSTALLLOCATION">
<Condition Level="0">INSTALLLEVEL=3 OR (MYTREAT="1" AND SPECIALVALUE)</Condition>
<ComponentRef Id="second_comp"/>
</Feature>
</Feature>
I had modified my code, but it's still not working right. Problem with conditions. There is a special value in registry key, but the installer is still skipping first feature. I had found that condition with just "MYTREAT=1" is not working. But in logs the client side is sending MYTREAT property with this value to the server.. INSTALLLEVEL is 1. MYTREAT property is initialized with pushbutton control,may be here is my trouble? Here new code:
<Feature Id="Myfeatures" Level="3"
ConfigurableDirectory='INSTALLLOCATION'
Display='expand' AllowAdvertise='no'>
<Condition Level='1'>MYTREAT="1"</Condition>
<ComponentRef Id='Empty'/>
<Feature Id='First' Level='3' AllowAdvertise='no'
ConfigurableDirectory='INSTALLLOCATION'> <!--Must be installed by default,default value of INSTALLLEVEL is 3-->
<Condition Level="1">MYTREAT="1" AND SPECIALVALUE="SPECIAL"</Condition>
<ComponentRef Id="first_comp"/>
</Feature>
<Feature Id="Second" Level="10" AllowAdvertise="no"
ConfigurableDirectory="INSTALLLOCATION"><!---->
<Condition Level="1">(MYTREAT="1" AND NOT SPECIALVALUE)</Condition>
<ComponentRef Id="second_comp"/>
</Feature>
</Feature>
............
<Dialog Id="TreatDlg" Width="260" Height="85">
<Control Id="Mytreat" Type="PushButton" X="50" Y="57" Width="56" Height="17" Property="MYTREAT">
<Publish Property="MYTREAT" Value="1">1</Publish>
<Publish Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
</Control>
P.S. I initialized MYTREAT with 1 by default and condition was evaluated correctly. Why I cannot use control's property in feature's condition? And how to resolve my problem!Please any help!
A common mistake is trying to control features through INSTALLLEVEL property. The install level should be static, you shouldn't change it during install.
The INSTALLLEVEL value is considered a level above which features are no longer installed. For example, if INSTALLLEVEL = 5 a feature with Level 4 will be installed and a feature with Level 6 will not be installed.
Through INSTALLLEVEL you can control the original feature state, for example:
<Feature Id="MyFeatures" Level="4" ConfigurableDirectory='INSTALLLOCATION' Display='expand' AllowAdvertise='no'>
<!-- Feature is not installed by default -->
<Feature Id='First' Level='6' AllowAdvertise='no' ConfigurableDirectory='INSTALLLOCATION'/>
<!-- Feature is installed by default -->
<Feature Id="Second" Level="4" AllowAdvertise="no" ConfigurableDirectory="INSTALLLOCATION"/>
</Feature>
For the above configuration you can then add install conditions by setting a Level lower or higher than INSTALLLEVEL:
<Feature Id="MyFeatures" Level="4" ConfigurableDirectory='INSTALLLOCATION' Display='expand' AllowAdvertise='no'>
<Feature Id='First' Level='6' AllowAdvertise='no' ConfigurableDirectory='INSTALLLOCATION'>
<Condition Level="4">(MYTREAT="1") AND (SPECIALVALUE="special")</Condition>
</Feature>
<Feature Id="Second" Level="4" AllowAdvertise="no" ConfigurableDirectory="INSTALLLOCATION">
<Condition Level="6">(INSTALLLEVEL = 3) OR (MYTREAT="1" AND SPECIALVALUE)</Condition>
</Feature>
</Feature>
As you can see, the feature Level attributes revolve around INSTALLLEVEL, not the other way around.
Edit:
Feature conditions are evaluated before any installation dialogs are shown. So you cannot condition a feature with a dialog control (for example a checkbox or a button).
A solution would be to use a custom action which modifies the feature action based on your custom property. For example you can use MsiSetFeatureState function. You can find a custom action tutorial here: http://www.codeproject.com/KB/install/msicustomaction.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With