Combobox WiX:基于组合框选择安装组件

Combobox WiX:基于组合框选择安装组件,combobox,wix,conditional-statements,Combobox,Wix,Conditional Statements,我正在尝试创建一个安装程序,它根据组合框的选择安装一些组件,但似乎条件不起作用。我声明组合框如下: ... <UI> <ComboBox Property="Option"> <ListItem Text="Red" Value="red" /> <ListItem Text="Blue" Value="blue" /> <ListItem Text="Green" Value="green" /> &l

我正在尝试创建一个安装程序,它根据组合框的选择安装一些组件,但似乎条件不起作用。我声明组合框如下:

...
<UI>
  <ComboBox Property="Option">
    <ListItem Text="Red" Value="red" />
    <ListItem Text="Blue" Value="blue" />
    <ListItem Text="Green" Value="green" />
  </ComboBox>
...
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
  <Component Id="MainComponent">
    <File Id="exe" Name="Main.exe" Source="Main.exe" />
  </Component>
  <Component Id="ComponentRed">
    <Condition>Option=red</Condition>
    <File Id="R" Name="config.txt" Source="red.txt" />
  </Component>
  <Component Id="ComponentBlue">
    <File Id="B" Name="config.txt" Source="blue.txt" />
    <Condition>Option=blue</Condition>
  </Component>
  <Component Id="ComponentGreen">
    <File Id="G" Name="config.txt" Source="green.txt" />
    <Condition>Option=green</Condition>
  </Component>
</ComponentGroup>
。。。
...
我有一个特点:

<Feature Id="ProductFeature" Title="MyProgram" Level="1">
  <ComponentGroupRef Id="ProductComponents" />
</Feature>

组件组声明如下:

...
<UI>
  <ComboBox Property="Option">
    <ListItem Text="Red" Value="red" />
    <ListItem Text="Blue" Value="blue" />
    <ListItem Text="Green" Value="green" />
  </ComboBox>
...
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
  <Component Id="MainComponent">
    <File Id="exe" Name="Main.exe" Source="Main.exe" />
  </Component>
  <Component Id="ComponentRed">
    <Condition>Option=red</Condition>
    <File Id="R" Name="config.txt" Source="red.txt" />
  </Component>
  <Component Id="ComponentBlue">
    <File Id="B" Name="config.txt" Source="blue.txt" />
    <Condition>Option=blue</Condition>
  </Component>
  <Component Id="ComponentGreen">
    <File Id="G" Name="config.txt" Source="green.txt" />
    <Condition>Option=green</Condition>
  </Component>
</ComponentGroup>

选项=红色
选项=蓝色
选项=绿色

属性需要是公共的(大写),并且需要在CDATA中进行比较。您可以使用不区分大小写的比较
~=

<Component Id="ComponentRed" Guid="*" Directory="INSTALLFOLDER">
    <File Id="R" Name="red.txt" Source="red.txt" />
    <Condition>
        <![CDATA[OPTION~="Red"]]>
    </Condition>
</Component>

<Control Id="MyComboBox" Type="ComboBox" X="20" Y="140" Width="56" Height="17"
         Property="OPTION">
    <ComboBox Property="OPTION">
        <ListItem Text="Red" Value="Red" />
        <ListItem Text="Blue" Value="Blue" />
        <ListItem Text="Green" Value="Green" />
    </ComboBox>
</Control>