情况是,我想在对话框中有一个复选框。如果复选框选中我要创建文件并执行其他操作。
我有一个自定义操作,应使用复选框属性的值。
现在,我尝试将复选框值传递给我的CA方法,但它从未收到值,该变量存在,但始终为空。我假设复选框变量本身目前不存在,因为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" />
在这种情况下,即使我取消选中该框,也总是如此。我尝试了空值(编译器说该属性将被忽略)
有人可以告诉我解决方案吗?
看来您正在使用延迟的上下文运行自定义操作,我认为这是导致您出现问题的原因。通读Obtaining Context Information for Deferred Execution Custom Actions。如果将您的财产放在CustomActionData中,那么它应该可用。