WiX条件注册表项



我正在进行我的第一个WiX项目,我很难让一些注册表项正常工作。

我的要求是,在设置中有一个选项来选择软件是安装在台式电脑上还是安装在飞机上。由于没有任何自动检测的方法,我创建了一个带有一些单选按钮的额外UI屏幕。(这在一个单独的文件中)

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<UI>
<Dialog Id="AircraftDesktopDlg_Custom"
Width="370"
Height="270"
Title="!(loc.InstallDirDlg_Title)">
<Control Type="RadioButtonGroup"
Property="InstallType_Prop"
Id="InstallType"
Width="200"
Height="42"
X="20"
Y="110">
<RadioButtonGroup Property="InstallType_Prop">
<RadioButton Text="Aircraft"
Height="17"
Value="0"
Width="50"
X="0"
Y="0" />
<RadioButton Text="Desktop"
Height="17"
Value="1"
Width="200"
X="0"
Y="20" />
</RadioButtonGroup>
</Control>
</Dialog>
</UI>
</Fragment>
</Wix>

代码清单1-单选按钮

然后,在我的主Product.wxs文件中,我有以下内容。

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product>
<Property Id="InstallType_Prop"
Value="0"/>
.
.
.
<DirectoryRef Id="TARGETDIR">
<Component Id="AircraftRegistryEntries"
Guid="E251C37B-2A4F-46D4-8E9F-24C66FB107E9">
<Condition>InstallType_Prop = 0</Condition>
<RegistryKey Root="HKLM"
Key="SoftwareCompanyProductv1.0"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="integer"
Name="OfflineMode"
Value="0"/>
<RegistryValue Type="integer"
Name="Simulator"
Value="0"/>
</RegistryKey>
</Component>
<Component Id="DesktopRegistryEntries"
Guid="CACDBBB6-BCAA-4B71-92BE-C762325580A3">
<Condition>InstallType_Prop = 1</Condition>
<RegistryKey Root="HKLM"
Key="SoftwareCompanyProductv1.0"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="integer"
Name="OfflineMode"
Value="1"/>
<RegistryValue Type="integer"
Name="Simulator"
Value="0"/>
</RegistryKey>
</Component>
</DirectoryRef>
.
.
.
<Feature Id='Complete'
Level='1'>
<ComponentRef Id='AircraftRegistryEntries'/>
<ComponentRef Id='DesktopRegistryEntries'/>
</Feature>
</Product>
</Wix>

代码清单2-属性和注册表项

如您所见,单选按钮与InstallType_Prop绑定。

我试图完成的是根据选择的单选按钮安装适当的注册表项。我在注册表组件中插入了这些条件,但它们似乎什么都没做。

我甚至不必这样做——如果选择了"桌面",我只需要将OfflineMode设置为1,如果选择了Aircraft,则需要将其设置为0。

我现在不知所措,我认为解决方案在于自定义操作或评估条件的顺序,但我不完全确定。

感谢您的帮助。

IMO通常的方法是将各种组件分组为(例如)两个功能,每种类型的系统一个,然后用户可以在标准功能树中选择合适的功能。在注册表项的情况下,每种类型的安装都有一个组件(用于注册表项),一个在一个功能中,另一个在另一个中。

最新更新