WiX - 功能条件不起作用

Dan*_*iel 5 windows-installer wix

我有一个 Wix-Installer 并向我的 TargetFolder-Selection-Dialog 添加了一个单选按钮组:

  <Property Id="INSTALLATION_TYPE" Secure="yes" Value="Server"/>
  <RadioButtonGroup Property="INSTALLATION_TYPE">
    <RadioButton Height="17" Text="Client" Value="Client" Width="342" X="0" Y="0" />
    <RadioButton Height="17" Text="Server" Value="Server" Width="342" X="0" Y="18" />
  </RadioButtonGroup>
Run Code Online (Sandbox Code Playgroud)

在服务器和客户端之间切换时,以下输出将打印到 MSI 日志文件中:

MSI (c) (04:B4) [17:17:56:295]: PROPERTY CHANGE: Modifying INSTALLATION_TYPE property. Its current value is 'Server'. Its new value: 'Client'.
Run Code Online (Sandbox Code Playgroud)

我的功能表锁定如下:

  <PropertyRef Id="INSTALLATION_TYPE"/>
  <Feature Id="CommonFeature" Level="1" Title="Common Feature">
    <ComponentGroupRef Id="Common"/>
    <ComponentGroupRef Id="RegistryKeys"/>

    <Feature Id="FeatureServer" Title="Server" Level="2">
      <Condition Level="1"><![CDATA[INSTALLATION_TYPE="Server"]]></Condition>
      <ComponentGroupRef Id="Server"/>
      <ComponentGroupRef Id="AdminConsole"/>
    </Feature>

    <Feature Id="FeatureClient" Title="Client" Level="2">
      <Condition Level="1"><![CDATA[INSTALLATION_TYPE="Client"]]></Condition>
      <ComponentGroupRef Id="Client"/>
    </Feature>
  </Feature>
Run Code Online (Sandbox Code Playgroud)

但是,当选择单选按钮“客户端”时,永远不会安装功能客户端和服务器。始终安装功能服务器。日志文件内容如下:

MSI (s) (DC:5C) [17:18:35:750]: Feature: FeatureServer; Installed: Absent;   Request: Null;   Action: Null
MSI (s) (DC:5C) [17:18:35:753]: Feature: FeatureClient; Installed: Absent;   Request: Null;   Action: Null
MSI (s) (DC:5C) [17:18:35:755]: Feature: CommonFeature; Installed: Absent;   Request: Local;   Action: Local
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

Bri*_*and 2

尝试在安装程序的 <Product> 部分中定义 INSTALLATION_TYPE。

我认为发生的情况是,您仅在安装的客户端(UI)中定义 INSTALLATION_TYPE 属性,即使它被标记为安全。

在日志的小片段中我们可以看到

MSI (c)

这表明这部分日志记录是在安装的 UI 部分期间发生的。然而,

MSI

表示此日志记录是在安装的服务器(提升)部分期间发生的。

在安装文件的末尾,您可能有一堆这样开头的行

财产(S)

所有带有 (S) 的属性都是安装的提升部分可以访问的。我敢打赌 INSTALLATION_TYPE 未在 (S) 属性中列出,并且您只是在技术上为安装的 UI(客户端)部分定义了它。这可以解释为什么您的客户端或服务器功能都没有安装。

此外,当使用默认情况下“不安装”的有条件安装的功能时,您需要将“或已安装”添加到打开它们的条件中。

当我编写一些安装程序时,我有默认关闭的功能,如果我安装了它们,则在卸载或升级过程中会出现问题(我不记得是哪个),导致安装程序无法正确完全卸载。这使得机器处于奇怪的状态,安装程序无法工作。将“或已安装”条件添加到功能启用条件中解决了我的这个问题。