variables - WIX 将复选框值传递给自定义操作
问题描述
情况是,我想在对话框中有一个复选框。如果选中该复选框,我想创建一个文件并做一些其他的事情。
我有一个自定义操作应该使用复选框属性的值。
现在我尝试将复选框值传递给我的 CA-Method 但它从未收到值,变量存在但始终为空。我假设此时复选框变量本身不存在,因为 session.CustomActionData.ToString() 显示:
INSTALLFOLDER=C:\Program Files (x86)\WixTesterSetup\;CHECKBOXProperty=
我的对话框是:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<UI Id="UserRegDialogUI">
<Property Id="Proceed">proceedbtn</Property>
<Dialog Id="UserRegDialog" Width="400" Height="300" Title="Atled Service Konfiguration">
<Control Id="headerText" Type="Text" X="65" Y="10" Width="350" Height="40" Transparent="yes" Text="Something to Check" />
<Control Id="checkboxLabel" Type="Text" X="58" Y="150" Height="14" Width="141" Transparent="yes" Text="Checkbox Text" />
<Control Id="checkbox" Type="CheckBox" X="60" Y="165" Height="17" Width="120" Property="CHECKBOXProperty" CheckBoxValue="true" />
<Control Id="proceedButton" Type="PushButton" Text="Weiter" Height="20" Width="43" X="349" Y="266">
<Publish Event="EndDialog" Value="Return">1</Publish>
</Control>
<Control Id="cancelButton" Type="PushButton" Text="Beenden" Height="22" Width="50" X="293" Y="266" Cancel="yes">
<Publish Event="EndDialog" Value="Exit" />
</Control>
</Dialog>
</UI>
<InstallUISequence>
<Show Dialog="UserRegDialog" Before="ExecuteAction" />
</InstallUISequence>
</Fragment>
</Wix>
Product.wsx 包含:
<Binary Id="CustomActionBinary" SourceFile="$(var.RegistrationInfoCustomAction.TargetDir)$(var.RegistrationInfoCustomAction.TargetName).CA.dll"/>
<CustomAction Id="RegistrationInfoCustomAction" BinaryKey="CustomActionBinary" DllEntry="SaveUserInfo" Execute="deferred" Impersonate="no" />
<CustomAction Id="CustomAction51" Property="RegistrationInfoCustomAction" Value="INSTALLFOLDER=[INSTALLFOLDER];CHECKBOXProperty=[CHECKBOXProperty]" />
<InstallExecuteSequence>
<Custom Action="CustomAction51" Before='InstallFinalize' />
<Custom Action='RegistrationInfoCustomAction' After='CustomAction51'>NOT Installed</Custom>
</InstallExecuteSequence>
我试图初始化设置属性:
<Property Id="CHECKBOXProperty" Value="true" />
在这种情况下,即使我取消选中该框,它也总是正确的。我尝试了空值(编译器说该属性将被忽略)
有人可以告诉我一个解决方案吗?
解决方案
看起来您正在使用延迟上下文运行自定义操作,我认为这就是导致您的问题的原因。通读获取延迟执行自定义操作的上下文信息。如果您将您的属性放在CustomActionData中,那么它应该是可用的。
推荐阅读
- mongodb - Mongo 安全数据库
- c++ - 我正在上 C++ 的 udemy 课程,在运行我的程序时出现“WinMain@16”错误
- javascript - 如果语句不起作用,为什么这个简单(嵌套)?
- python - 由 conda 列出但无法导入的 Pytorch
- xamarin.forms - 如何更改不同主题的工具栏项(徽标)
- algorithm - 上限和下限是什么意思?
- java - 创建一个具有 2 个给定数组的方法,该方法返回一个新数组,其中包含来自 a 和 b 的元素且没有重复项:
- angular - 角度单元测试 - 单击按钮时未检测到更改
- javascript - 如何使用 ionic /Angular 正确处理用于注销和处理多个 url 的 jwt 令牌
- javascript - 如何从 html 中的内联 js 脚本中获取变量并将其放入外部 .js 文件中?