首页 > 解决方案 > 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" />

在这种情况下,即使我取消选中该框,它也总是正确的。我尝试了空值(编译器说该属性将被忽略)

有人可以告诉我一个解决方案吗?

标签: variablescheckboxwixcustom-actionwix3.7

解决方案


看起来您正在使用延迟上下文运行自定义操作,我认为这就是导致您的问题的原因。通读获取延迟执行自定义操作的上下文信息。如果您将您的属性放在CustomActionData中,那么它应该是可用的。


推荐阅读