wix - 使用属性值的 WIX 自定义操作条件不起作用
问题描述
我试图在我的 Wix 安装程序结束时运行自定义操作,但前提是满足某些条件。用户运行安装程序,他们将选择设置属性“ServiceType”的两种模式之一。该属性的两个值是“RegisterNew”和“LinkExisting”。您可以通过下面的日志看到,当用户在 UI 中选择“LinkExisting”时,它会更改属性,但自定义操作仍会运行。
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>
这是用户界面的图像:
所以我的问题是为什么即使我的条件专门检查该属性,它也会执行自定义操作?
解决方案
在阅读了一些文档并查看了 WIX 中标签的所有“属性”之后,我决定尝试设置一些其他值,看看会发生什么。我发现在定义属性时,如果您将其标记为安全,则它会在整个安装过程中保留其价值,而如果它不安全,它似乎不会这样做。所以现在我的属性定义如下所示:
<Property Id="SERVICE_TYPE" Secure="yes" Value="RegisterNew" />
您会注意到我必须将名称更改为大写字母,因为当您将属性标记为安全属性时,名称中不能包含任何小写字母。
以下是 WIX 文档的片段:
Secure -- YesNoType -- 表示在使用提升的权限进行托管安装时,可以将属性传递到服务器端。有关详细信息,请参阅 SecureCustomProperties 属性。
推荐阅读
- javascript - 滑动、延迟然后自动滑出的弹出窗口
- python - Django:补丁和发布需要管理员批准
- java - Hibernate Search OneToMany 混淆结果
- bash - 获取从 glob 扩展返回的文件的完整路径
- java - 如何将此峰度公式从 java 文档转换为 Ruby?
- python - .get + dict 变量
- c - Bazel:错误的语法寻址标头?
- telegram-bot - 使用 Telegram API BOT 在消息或文件中搜索
- forms - Thymeleaf 表 - 从带有表单标签的选定行发送 id
- python - Numpy 随机选择不适用于二维列表