使用 属性 值的 WIX 自定义操作条件不起作用

WIX Custom Action Condition using Property Value not working

我正在尝试 运行 在我的 Wix 安装程序结束时执行自定义操作,但前提是满足特定条件。用户 运行 通过安装程序,他们将选择设置 属性 'ServiceType' 的两种模式之一。 属性 的两个值是 "RegisterNew" 和 "LinkExisting"。您可以通过下面的日志看到,当用户在 UI 中选择 "LinkExisting" 时,它会更改 属性 但自定义操作仍然是 运行s.

MSI (c) (D4:44) [11:20:15:686]: PROPERTY CHANGE: Modifying ServiceType property. Its current value is 'RegisterNew'. Its new value: 'LinkExisting'.

这是我的自定义操作代码:

<InstallExecuteSequence>
  <Custom Action="RegisterServiceNameCustomAction" Before="InstallFinalize">
    <![CDATA[(ServiceType="RegisterNew") AND (NOT Installed)]]>
  </Custom>
</InstallExecuteSequence>

  <Fragment>
    <Binary Id="RegisterServiceCustomActionBinary" SourceFile="$(var.RegisterServiceCustomAction.TargetDir)$(var.RegisterServiceCustomAction.TargetName).CA.dll" />
    <CustomAction Id="RegisterServiceNameCustomAction" BinaryKey="RegisterServiceCustomActionBinary" DllEntry="ShowRegisterService" Execute="deferred" Return="check" />
  </Fragment>

以下是我尝试过的不同条件:

(ServiceType="RegisterNew") AND (NOT Installed)

<![CDATA[(ServiceType="RegisterNew") AND (NOT Installed)]]>

ServiceType="RegisterNew" AND NOT Installed

这是我的自定义对话框的代码,他们在其中进行选择,做出将更改的选择 "ServiceType":

    <?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
    <UI Id="SelectServiceDlg">
      <Property Id="ServiceType" Value="RegisterNew" />
      <Dialog Id="SelectServiceDlg" Width="370" Height="270" Title="[ProductName] [Setup]" NoMinimize="yes">
        <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="[DialogBitmap]" />
        <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
        <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
        <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="40" Transparent="yes" NoPrefix="yes" Text="Determine whether you need to register a new service or link an existing service." />
        <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="Service Type Selection" />
        <Control Id="BothScopes" Type="RadioButtonGroup" X="20" Y="55" Width="330" Height="120" Property="ServiceType">
         <RadioButtonGroup Property="ServiceType">
            <RadioButton Value="RegisterNew" X="0" Y="0" Width="295" Height="16" Text="Register New Service" />
            <RadioButton Value="LinkExisting" X="0" Y="60" Width="295" Height="16" Text="Link Existing Service" />
          </RadioButtonGroup>
        </Control>
        <Control Id="RegisterNewServiceDescription" Type="Text" X="33" Y="70" Width="300" Height="36" NoPrefix="yes" Text="Select this option if you are going to register a new service.">
        </Control>
        <Control Id="LinkExistingDescription" Type="Text" X="33" Y="130" Width="300" Height="36" NoPrefix="yes" Text="Select this option if you are going to link an existing service to this service.">
        </Control>
        <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />
        <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)" />
        <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
          <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
        </Control>
      </Dialog>
    </UI>
    </Fragment>
</Wix>

这是 UI 的图像:

所以我的问题是为什么它执行自定义操作,即使我的条件是专门检查 属性?

在阅读了一些文档并查看了 WIX 中标签的所有 "properties" 之后,我决定尝试设置几个其他值,看看发生了什么。我发现在定义 属性 时,如果您将其标记为安全,那么它会在整个安装过程中保留其值,而如果它不安全,它似乎不会这样做。所以现在我的 属性 定义是这样的:

<Property Id="SERVICE_TYPE" Secure="yes" Value="RegisterNew" />

您会注意到我必须将名称更改为大写字母,因为当您将 属性 标记为安全 属性 时,名称中不能包含任何小写字母。

这是 WIX 文档中的一个片段:

Secure -- YesNoType -- 表示在使用提升的权限进行托管安装时可以将 属性 传递到服务器端。有关详细信息,请参阅 SecureCustomProperties 属性。

WIX Documentation For Property Element