将功能与WiX中的复选框关联

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将功能与WiX中的复选框关联相关的知识,希望对你有一定的参考价值。

我的Product.wxs中有一些功能(Complete,有2个子功能,即AppFeature和DBFeature),如下所示。

 <Feature InstallDefault="local" Description="!(loc.FullFeatureDesc)" Title="!(loc.FullFeatureTitle)" Level="1" Id="Complete" Absent="allow" AllowAdvertise="no" Display="expand">
      <Feature InstallDefault="local" Description="!(loc.AppFeatureDesc)" Title="!(loc.AppFeatureTitle)" Level="1" Id="AppFeature" Absent="allow" AllowAdvertise="no" Display="expand">
        <ComponentGroupRef Id="AppCG"/>
      </Feature>
      <Feature InstallDefault="local" Description="!(loc.DBFeatureDesc)" Title="!(loc.DBFeatureTitle)" Level="1" Id="DBFeature" Absent="allow" AllowAdvertise="no" Display="expand">
        <ComponentGroupRef Id="DbCG"/>
      </Feature>
    </Feature>

在另一个对话框中,我有一些All,App和DB选项的复选框,每个选项都用于一个功能(All表示App和DB)。我想将App复选框与App功能相关联,将DB复选框与DB Feature关联。我使用Event =“AddLocal”和Value =“AppFeature”在该对话框的Next按钮中使用Publish元素尝试了它,并使用了一个DBFeature,并且选中了复选框值。但是点击“下一步”按钮,没有任何反应。谁能帮帮我吗?我还提供对话框中的元素以供参考。

<Control Id="ControlAllFeature" Type="CheckBox" X="180" Y="33" Width="140" Height="17"
    Property="ALLFEATURES_CHECKED" CheckBoxValue="AllFeatureValue" Text="Install Everything">
          <Publish Property="APPFEATURE_CHECKED" Value="AppFeatureValue" Order="1">ALLFEATURES_CHECKED</Publish>
          <Publish Property="APPFEATURE_CHECKED" Value="{}" Order="2">NOT ALLFEATURES_CHECKED</Publish>
          <Publish Property="DBFEATURE_CHECKED" Value="DBFeatureValue" Order="3">ALLFEATURES_CHECKED</Publish>
          <Publish Property="DBFEATURE_CHECKED" Value="{}" Order="4">NOT ALLFEATURES_CHECKED</Publish>      
        </Control>
        <Control Id="ControlAppFeature" Type="CheckBox" X="191" Y="50" Width="140" Height="17"
     Property="APPFEATURE_CHECKED" CheckBoxValue="AppFeatureValue" Text="Install Application">
          <Publish Property="ALLFEATURES_CHECKED" Value="{}" Order="1">NOT APPFEATURE_CHECKED</Publish>
          <Publish Property="ALLFEATURES_CHECKED" Value="AllFeatureValue" Order="2">APPFEATURE_CHECKED AND DBFEATURE_CHECKED</Publish>
        </Control>
        <Control Id="ControlDBFeature" Type="CheckBox" X="191" Y="67" Width="140" Height="17"
           Property="DBFEATURE_CHECKED" CheckBoxValue="DBFeatureValue" Text="Install DB">
          <Publish Property="ALLFEATURES_CHECKED" Value="{}" Order="1">NOT DBFEATURE_CHECKED</Publish>
          <Publish Property="ALLFEATURES_CHECKED" Value="AllFeatureValue" Order="2">APPFEATURE_CHECKED AND DBFEATURE_CHECKED</Publish>
        </Control>

        <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;Back">
          <Publish Event="NewDialog" Value="CustLicenseAgmtDlg">1</Publish>
        </Control>
        <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&amp;Next">
          <Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">CostingComplete = 1</Publish>
          <Publish Event="NewDialog" Value="BrowsePathDlg"></Publish>
           <Condition Action="disable">NOT APPFEATURE_CHECKED OR NOT DBFEATURE_CHECKED</Condition>
          <Condition Action="enable">APPFEATURE_CHECKED OR DBFEATURE_CHECKED</Condition>
         <Publish Event="Remove" Value="ALL" Order="1">1</Publish>
         <Publish Event="AddLocal" Value="AppFeature" Order="2">APPFEATURE_CHECKED</Publish>
         <Publish Event="AddLocal" Value="DBFeature" Order="3">DBFEATURE_CHECKED</Publish>
        </Control>
        <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
          <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
        </Control>

我为此提到了下面的链接,但无法使其正常工作。任何帮助将非常感激。

Wix 3.5, Install features based on checkboxes

答案

我改变了方法。实际上有两种方式。一种是在要素元素中的Product.wxs中执行此操作以获得条件。另一个提供更好的控制。下面的标记解释了它。

<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&amp;Next">
          <Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">CostingComplete = 1</Publish>
          <Publish Event="NewDialog" Value="BrowsePathDlg">1</Publish>
             <Condition Action="disable">NOT APPFEATURE_CHECKED OR NOT DBFEATURE_CHECKED OR (((!AppFeature = 3) AND (!DBFeature = 2) AND NOT DBFEATURE_CHECKED) AND ((!DBFeature = 3) AND (!AppFeature = 2) AND NOT APPFEATURE_CHECKED)) OR ((!AppFeature = 3) AND (!DBFeature = 3))</Condition>
          <Condition Action="enable">(APPFEATURE_CHECKED OR DBFEATURE_CHECKED) AND (((!AppFeature = 2) AND APPFEATURE_CHECKED) OR ((!DBFeature = 2) AND DBFEATURE_CHECKED))</Condition>
           <Publish Event="AddLocal" Value="ALL">1</Publish> 
          <Publish Event="Remove" Value="AppFeature"><![CDATA[APPFEATURE_CHECKED <> "1"]]></Publish>
          <Publish Event="Remove" Value="DBFeature"><![CDATA[DBFEATURE_CHECKED <> "1"]]></Publish>
        </Control>

我之前缺少的是Publish NewDialog事件中的值1。一旦我添加它,它就开始工作并单击Next按钮,将我带到下一个对话框。

另一答案

试试这个:

在你的孩子将来把它放在0级,然后他们在她的内部设置一个条件来验证是否选中了复选框

<Feature InstallDefault="local" Description="!(loc.FullFeatureDesc)" Title="!(loc.FullFeatureTitle)" Level="1" Id="Complete" Absent="allow" AllowAdvertise="no" Display="expand">
  <Feature InstallDefault="local" Description="!(loc.AppFeatureDesc)" Title="!(loc.AppFeatureTitle)" Level="0" Id="AppFeature" Absent="allow" AllowAdvertise="no" Display="expand">
    <ComponentGroupRef Id="AppCG"/><Condition Level="1">APPFEATURE_CHECKED</Condition>
  </Feature>
  <Feature InstallDefault="local" Description="!(loc.DBFeatureDesc)" Title="!(loc.DBFeatureTitle)" Level="1" Id="DBFeature" Absent="allow" AllowAdvertise="no" Display="expand">
    <ComponentGroupRef Id="DbCG"/>
  </Feature>
</Feature>

以上是关于将功能与WiX中的复选框关联的主要内容,如果未能解决你的问题,请参考以下文章

WIX 中功能的自定义操作

使用条件元素禁用 WIX 中的复选框

WiX:有条件地注册应用程序以在 Windows 启动时启动

片段中的 super.onCreateView

ViewPager 中的片段没有与之关联的活动

如何使用模块化代码片段中的LeakCanary检测内存泄漏?