How to set functions depending on the value of a property

I have a registry key that can be equal to one of two values: a special value or null. And two features.

When my registry key has special meaning, the installer must install the first function. if the registry key is not found as a result of a registry search, the installer must install the second function. And if the registry key is null, the installer should not install any of these two functions.

What am I doing or misunderstanding? If INSTALLLEVEL = 5, SPECIALVALUE = "special", MYTREAT = "1", the first function must be installed, but the installer does not install both functions 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 changed my code, but it still does not work. Problem with the conditions. The registry key has a special meaning, but the installer still skips the first function. I found that the condition with "MYTREAT = 1" does not work. But in the logs, the client side sends the MYTREAT property with this value to the server. INSTALLLEVEL is 1. The MYTREAT property is initialized using the button control, maybe this is my problem? Here's the 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> 

PS I initialized MYTREAT with 1 by default and the condition was evaluated correctly. Why can't I use a control property in a function state? And how to solve my problem! Please, help!

+4
source share
1 answer

A common mistake is trying to control functions through the INSTALLLEVEL property. The installation level must be static; you must not change it during installation.

The INSTALLLEVEL value is considered the level above which the functions are no longer installed. For example, if INSTALLLEVEL = 5, a level 4 function will be installed, and a function with level 6 will not be installed.

Through INSTALLLEVEL you can control the initial state of the function, 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> 

In the above configuration, you can add installation 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, Level attributes revolve around INSTALLLEVEL, and not vice versa.

Edit:

Function conditions are evaluated before all installation dialogs are displayed. Therefore, you cannot set a function using a dialog control (for example, a check box or button).

The solution is to use a custom action that modifies the action of the function based on your custom property. For example, you can use the MsiSetFeatureState function. Here you can find a special action tutorial: http://www.codeproject.com/KB/install/msicustomaction.aspx

+7
source

All Articles