我们可以将 KeyPath="no" 与 "Component" 元素与注册表一起使用吗

Can we use KeyPath="no" with the "Component" element along with the Registry

我已经为我的项目生成了 windows 安装程序包(.msi 文件)。

我安装了安装程序,但之后我无法启动该应用程序。

所以,我正在检查 .wxs 文件以找到根本原因并找到一些可疑代码

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
  <Fragment>
    <DirectoryRef Id="INSTALLDIR">

      <!-- This component creates EMR v3.0 Registry Entries-->

      <Component Id="RegistryEntries_Set1" Guid="1A20601C-77EA-11E0-98C2-1AD64824019B" KeyPath="no">
        <!-- To remove stray registry entries under HKLM,HKU and HKCU registry hives-->
        <!--<Registry Id="Delete$(var.CompanyName)Node" Root="HKLM" Key="Software$(var.CompanyName)$(var.ProductName)" Action="removeKeyOnUninstall" />-->
        <RegistryKey Id="Delete$(var.CompanyName)Node" Root="HKLM" Key="Software$(var.CompanyName)$(var.ProductName)" Action="createAndRemoveOnUninstall" />
        <RegistryKey Id="Delete$(var.CompanyName)Node2" Root="HKU" Key=".DEFAULT\Software$(var.CompanyName)" Action="createAndRemoveOnUninstall" />
        <RegistryKey Id="Delete$(var.CompanyName)Node3" Root="HKCU" Key="Software$(var.CompanyName)" Action="createAndRemoveOnUninstall" />

我理解如果 Keypath = "yes" 意味着,windows 安装程序认为 keypath 资源存在并且不会再次安装它。

如果 Keypath = "no",它将安装。

在此上下文中,我想知道 KeyPath="no" 的含义,并且还想了解此代码片段?

组件在这里做什么?

Wix documentation开始,如果组件中的KeyPath值未设置为'yes',它将自动尝试select组件内部声明的元素之一作为一个 KeyPath。

因此,在示例中显示的内容中,组件的第一个 RegistryKey 元素将被声明为 KeyPath。您的代码示例将在安装时创建 3 个注册表项(并在您卸载时删除它们),并且如果系统上存在自动 select 作为 KeyPath 的注册表项,则认为该组件已安装.