如何通过延迟自定义操作检索CustomActionData上设置的属性?
我有一个自定义操作,需要低于将安装文件夹中的某些部分复制到VS2010文件夹的值
VS2010DEVENV属性)INSTALLLOCATION属性)为了提供足够的权限,我将自定义操作设置为Execute='deferred' Impersonate='no'.但是在运行安装程序时,它会记录以下消息:
无法从非立即自定义操作访问会话详细信息
看来我们无法在"延期"自定义操作中访问属性(即session["VS2010DEVENV"])
有没有其他方法可以根据需要检索这些值?
在运行WiX设置时,我一直在查找操作列表及其顺序.不知何故官方网站似乎没有提供任何信息.
基本问题是我想正确安排自定义操作.通常我需要使用regsvr32.exe注册DLL,这只能在文件复制到硬盘后才能完成.但是自定义动作
<Custom Action="RegisterShellExt" After="InstallFiles">
Run Code Online (Sandbox Code Playgroud)
失败,错误消息"找不到文件".
我所做的就是使用WiX Edit分析我的MSI日志,我发现Action InstallFiles不止一次存在.实际上,文件只在第二次出现时写入.所以我将自定义操作更改为以下内容:
<Custom Action="RegisterShellExt" Before="InstallFinalize">
Run Code Online (Sandbox Code Playgroud)
这是我从MSI的日志中提取的序列:
Action start 15:16:49: INSTALL.
Action start 15:16:49: PrepareDlg.
Action start 15:16:49: AppSearch.
Action start 15:16:49: LaunchConditions.
Action start 15:16:49: ValidateProductID.
Action start 15:16:49: DIRCA_NEWRETARGETABLEPROPERTY1.5D429292039C46FCA3253E37B4DA262A.
Action start 15:16:50: CostInitialize.
Action start 15:16:50: FileCost.
Action start 15:16:50: CostFinalize.
Action start 15:16:50: WelcomeDlg.
Action 15:16:51: LicenseAgreementDlg. Dialog created
Action 15:16:53: CustomizeDlg. Dialog created
Action 15:16:55: VerifyReadyDlg. Dialog created
Action start 15:16:56: ProgressDlg.
Action start 15:16:56: ExecuteAction.
Action start 15:16:58: …Run Code Online (Sandbox Code Playgroud) UPDATE
这已经解决了,所以我已经为未来的读者更新了这篇文章
我在这方面遇到了困难.这里有很多 的 SO文章有关这些设置,但我被卡住了.
我的目标是执行两个步骤:
1)读取将与msi物理一起提供的文件.换句话说,将有三个文件setup.exe,test.msi,specialFile.txt
2)在安装过程中,我想在安装路径中创建一个新文件.C:\ Program Files\MyCompany\MyApplication \newFile.txt
步骤2中的文件是通过读取步骤1中的specialFile.txt中的内容创建的.
我的问题是导航WiX设置的模糊组合,以使我能够读取会话变量并具有足够高的权限来写出文件.这并不容易.
这是解决方案:
<Binary Id="MyCustomAction.CA.dll" SourceFile="path\to\MyCustomAction.CA.dll" />
<CustomAction Id="MyActionsName"
Return="check"
Execute="deferred"
BinaryKey="MyCustomAction.CA.dll"
DllEntry="MyCustomAction"
Impersonate="no"/>
<CustomAction Id="CustomAction1"
Property="MyActionsName"
Value="INSTALLFOLDER=[Get_This_From_Your_Directory_Tag];SOURCEDIR=[SourceDir]"/>
<InstallExecuteSequence>
<Custom Action="CustomAction1" Before="MyActionsName" />
<Custom Action="MyActionsName" Before="InstallFinalize">NOT Installed AND NOT PATCH</Custom>
</InstallExecuteSequence>
Run Code Online (Sandbox Code Playgroud)
impersonate="no" 为了有足够的privs来写文件"deferred"为了拥有足够的权限来写入文件Before="InstallFinalize",这是在安装文件之后. 然后在C#代码中,执行以下操作:
string sourceDir = session.CustomActionData["SOURCEDIR"]
string installFolder = session.CustomActionData["INSTALLFOLDER"]
Run Code Online (Sandbox Code Playgroud)
其他有用的参考文献:
本文介绍如何在不使用session ["SourceDir"]的情况下读取SourceDir,因为自定义操作是延迟的.