combobox - WiX:根据组合框选择安装组件

标签 combobox wix conditional-statements

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

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

组件Group声明如下:

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

最佳答案

该属性需要是公共(public)的(大写),并且比较需要在 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>

关于combobox - WiX:根据组合框选择安装组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30573738/

相关文章:

wix - 托管 Bootstrap : Failed while prompting for source

r - 如何在R中从具有多个条件的一个数据帧创建多个数据帧

有条件定义静态变量

excel - 在初始化和更改其他组合框时设置组合框值

java.lang.String 无法转换为 [Ljava.lang.Object;

java - 如何使用 beanitemcontainer 设置 vaadin 组合框值?

c# - 如何为 ComboBox 中的文件列表启用自动完成

.net - InstallExecuteSequence 表包含在两个不同位置声明的操作 'RemoveExistingProducts'

Windows 安装程序 : can two different installer share the same componet

javascript - 允许空白或数字值的正确正则表达式是什么