2011-09-26 44 views
4

我有一个注册表项可以等于两个值之一:特殊值null。和两个功能。如何安装功能取决于属性的值

当我的注册表项等于特殊值安装程序必须安装第一个功能。如果通过注册表搜索没有找到注册表项,安装程序必须安装第二个功能。如果注册表项具有null值,则安装程序不得安装这两个功能中的任何一个。

我在做什么或理解错误?如果INSTALLLEVEL = 5,SPECIALVALUE =“special”,MYTREAT =“1”,则必须安装第一个功能,但安装程序在这种情况下不会安装这两个功能。

<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> 

我修改了我的代码,但它仍然不能正常工作。有条件的问题。注册表项中有一个特殊的值,但安装程序仍在跳过第一个功能。我发现只有“MYTREAT = 1”的条件不起作用。但是在日志中,客户端正在用这个值向服务器发送MYTREAT属性.. INSTALLLEVEL是1. MYTREAT属性用按钮控制初始化,可能在这里是我的麻烦?新代码:

 <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.默认情况下,我初始化了MYTREAT 1,条件被正确评估。为什么我无法在功能条件下使用控件的属性?以及如何解决我的问题!请任何帮助!

回答

7

一个常见的错误是试图通过INSTALLLEVEL属性来控制功能。安装级别应该是静态的,在安装过程中不应更改它。

INSTALLLEVEL值被认为是高于此值的功能不再安装。例如,如果INSTALLLEVEL = 5,则将安装Level 4的功能,并且不会安装Level 6的功能。

通过INSTALLLEVEL可以控制原始特征状态,例如:

<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> 

对于上述结构然后可以通过设置一个级别低于或高于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> 

正如您所看到的,功能级别属性围绕着INSTALLLEVEL而不是其他方式。

编辑:示任何安装对话框之前

特征条件进行了评价。所以你不能使用对话框控件(例如复选框或按钮)来调节功能。

解决方案是使用基于自定义属性修改功能操作的自定义操作。例如,您可以使用MsiSetFeatureState函数。你可以在这里找到一个自定义操作教程: http://www.codeproject.com/KB/install/msicustomaction.aspx

+1

很奇怪,我认为我可以调节我的部件一个对话框控制。谢谢 – Nerielle

+0

是否有已经通过对话框来改变它的解决方案? “典型,完整”? –

相关问题