在 WiX 捆绑包中,如果找不到注册表项,如何阻止捆绑包启动?

In a WiX Bundle, how can I prevent the bundle from launching if I don't find a registry key?

我需要创建一个 WiX 包,除非系统上存在某个注册表项,否则不会运行。

在正常的安装项目中,我会使用启动条件,但我不是在编写安装项目,而是在编写顶级包。 <Bundle> 元素有一个 Condition 属性,但在 Burn 手册中它说:

The condition of the bundle. If the condition is not met, the bundle will refuse to run. Conditions are checked before the bootstrapper application is loaded (before detect), and thus can only reference built-in variables such as variables which indicate the version of the OS.

看来我不能将 Bundle 元素的 Condition 属性用于除了最基本的高级检查之外的任何东西,当然也不是我需要的。

那么我如何在包级别检查注册表项并在缺少该注册表项时拒绝继续?

您绝对可以在您的包中进行注册表搜索,然后根据这些注册表搜索的结果确定一个条件,因为我在几个引导程序项目中正是这样做的。不确定文档指的是什么,但它已经过时或错误。

作为一个简单的例子,我有:

<util:RegistrySearch
    Id="ServerInstalledCheck"
    Root="HKLM"
    Key="SOFTWARE$(var.OEMRegistryRootKeyName)"
    Value="ServerPath"
    Result="value"
    Variable="ServerInstalled"/>

<bal:Condition Message="#(loc.ServerNotInstalledError)" >ServerInstalled OR WixBundleInstalled</bal:Condition>

如果找不到服务器路径键@HKLM\SOFTWARE\$(var.OEMRegistryRooteKeyName)

,这将阻止您的包安装

我还添加了 OR WixBundleInstalled 因为您可能会遇到这样的问题:客户以某种方式卸载了您的引导程序中包含的全部或部分软件包(包括注册表搜索所依赖的软件包),然后您将在手动 re-add 注册表项之前永远无法卸载引导程序。