WiX:基于ComboBox选择安装组件

时间:2015-06-01 12:40:24

标签: combobox wix conditional-statements

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

...
<UI>
  <ComboBox Property="Option">
    <ListItem Text="Red" Value="red" />
    <ListItem Text="Blue" Value="blue" />
    <ListItem Text="Green" Value="green" />
  </ComboBox>
...

我有一个功能:

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

组件组声明如下:

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

1 个答案:

答案 0 :(得分:1)

该属性需要公开(大写),并且需要在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>