gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 05:31:21 26 4
gpt4 key购买 nike

我的WiX安装程序与推迟/立即的自定义操作联系时遇到问题。请原谅我的英语。

我想将用户输入的某些属性交还给延迟的自定义操作。我知道我需要立即执行自定义操作和执行“CustomActionData”。我已经以这种方式实现了。

二进制文件:

<Binary Id='myAction'  SourceFile='.\TemplateGeneration.CA.dll'/>

立即的自定义操作:
<CustomAction Id='Datenuebergabe' Property='DoSomething' Value='InstalllocVar=[INSTALLLOCATION]'/>

延迟的自定义操作:
<CustomAction Id='TemplateGenerationInstallKey' BinaryKey ='myAction' DllEntry='DoSomething' Impersonate='no' Execute='deferred'  Return='check' HideTarget='yes'/>

InstallExecuteSequence
 <InstallExecuteSequence>

<Custom Action="Datenuebergabe" Sequence="1399"/>
<Custom Action="TemplateGenerationInstallKey" Before="InstallFinalize"/>

</InstallExecuteSequence>

在延迟的自定义操作中调用属性:
string somedata = session.CustomActionData["InstalllocVar"];
TemplateEngineCall(somedata+"templates", "install_key_cmd", somedata+"scripts", "install_key.cmd");

我的问题:
如果我尝试安装程序,则会中断。
使用此代码,我只能移交一个属性,但是我需要提交多个属性。

有关信息:
当我查看日志文件时,在执行自定义操作时出现了System.Collections.Generic.KeyNotFoundException。

为什么不起作用?
好吧,我需要推迟自定义操作才能将其写入“程序文件文件夹”。由于具有所需的权限,因此需要延迟的自定义操作,并且在延迟前执行的立即自定义操作应有助于处理属性。有可能这样做吗?

希望您了解我的问题,并且可以尝试帮助我。

最佳答案

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

<!-- 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异常的问题。

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

首先,在直接CA中,使用 ;分隔符传递名称-值集合,如下所示:
<CustomAction Id="SetForDoSomething" Return="check" Property="DoSomething" Value="source=[ArchiveFolder][ARCHIVENAME];target=[WebsiteFolder]"/>

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

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

就是这样。

关于WiX-提交多个属性以延迟自定义操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19628906/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com