且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WiX-提交多个属性以延迟自定义操作

更新时间:2022-05-02 00:11:34

首先,将数据从立即自定义操作传递到延迟的操作中存在一个错误。您在立即自定义操作中使用的属性的名称必须与延迟自定义的 Id 完全相同行动。在您的情况下:

First of all, there's a mistake in the way you pass the data from immediate custom action to the deferred one. The name of the Property you use in the immediate custom action must be exactly the same as the Id of the deferred custom action. In your case:

<!-- immediate CA -->
<CustomAction Id='Datenuebergabe' Property='DoSomething' Value='InstalllocVar=[INSTALLLOCATION]'/>

<!-- deferred CA -->
<CustomAction Id='DoSomething' BinaryKey ='myAction' DllEntry='DoSomething' Impersonate='no' Execute='deferred'  Return='check' HideTarget='yes'/>

这将解决带有 KeyNotFound 异常的问题。

This will resolve the problem with KeyNotFound exception.

现在,回到您的问题,如何传递多个值。

Now, back to your question how to pass more than 1 value.

首先,立即CA使用; 分隔符传递名称-值集合,如下所示:

First, in the immediate CA use ; separator to pass the name-value collection, like this:

<CustomAction Id="SetForDoSomething" Return="check" Property="DoSomething" Value="source=[ArchiveFolder][ARCHIVENAME];target=[WebsiteFolder]"/>

如您所见,这里有2个名称/值对传递给延迟的CA,目标。在延迟的CA中,使用以下代码将这些值取出:

As you can see, there are 2 name-value pairs we pass to the deferred CA here, source and target. In the deferred CA, use the following code to take those values out:

var source = session.CustomActionData["source"];
var target = session.CustomActionData["target"];

就是这样。