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