Sch*_*jen 8 installer custom-action wix wix-extension wix3.6
我的WiX安装程序与延迟/立即自定义操作联系时遇到问题.请原谅我的英语.
我想将用户输入的一些属性交给延迟的自定义操作.我知道我需要一个立即的自定义操作和"CustomActionData"来做到这一点.我是以这种方式实施的.
二进制文件:
<Binary Id='myAction' SourceFile='.\TemplateGeneration.CA.dll'/>
Run Code Online (Sandbox Code Playgroud)
即时自定义操作:
<CustomAction Id='Datenuebergabe' Property='DoSomething' Value='InstalllocVar=[INSTALLLOCATION]'/>
Run Code Online (Sandbox Code Playgroud)
延迟的自定义操作:
<CustomAction Id='TemplateGenerationInstallKey' BinaryKey ='myAction' DllEntry='DoSomething' Impersonate='no' Execute='deferred' Return='check' HideTarget='yes'/>
Run Code Online (Sandbox Code Playgroud)
InstallExecuteSequence
<InstallExecuteSequence>
<Custom Action="Datenuebergabe" Sequence="1399"/>
<Custom Action="TemplateGenerationInstallKey" Before="InstallFinalize"/>
</InstallExecuteSequence>
Run Code Online (Sandbox Code Playgroud)
在延迟的自定义操作中调用属性:
string somedata = session.CustomActionData["InstalllocVar"];
TemplateEngineCall(somedata+"templates", "install_key_cmd", somedata+"scripts", "install_key.cmd");
Run Code Online (Sandbox Code Playgroud)
我的问题:如果我尝试安装我的程序就会中断.使用此代码我只能放弃一个属性,但我需要提交多个.
有关信息:当我查看日志文件时,自定义操作调用时会出现System.Collections.Generic.KeyNotFoundException.
为什么这不起作用?好吧,我需要延迟的自定义操作写入"程序文件文件夹".由于所需的权限,需要延迟的自定义操作,并且在延迟之前执行的立即自定义操作应该有助于处理属性.有可能吗?
我希望你明白我的问题是什么,你可以尝试帮助我.
Yan*_*nko 16
首先,将数据从即时自定义操作传递到延迟操作的方式存在错误.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'/>
Run Code Online (Sandbox Code Playgroud)
这将解决KeyNotFound
异常问题.
现在,回到你的问题如何传递超过1的值.
首先,在即时CA中使用;
分隔符来传递名称 - 值集合,如下所示:
<CustomAction Id="SetForDoSomething" Return="check" Property="DoSomething" Value="source=[ArchiveFolder][ARCHIVENAME];target=[WebsiteFolder]"/>
Run Code Online (Sandbox Code Playgroud)
如您所见,我们在此处传递了两个名称 - 值对,source
并且target
.在延迟CA中,使用以下代码将这些值取出:
var source = session.CustomActionData["source"];
var target = session.CustomActionData["target"];
Run Code Online (Sandbox Code Playgroud)
就是这样.
归档时间: |
|
查看次数: |
6254 次 |
最近记录: |