如何通过延迟自定义操作检索CustomActionData上设置的属性?
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,因为自定义操作是延迟的.
我正在使用 dll 来安装打包在 msi 中的驱动程序。当我在 InstallFinalize 之后安排自定义操作时,它会成功,但是如果我在 1) InstallFiles 之后 2) 在 InstallFiles 之后,execute=deferred,3) 在 InstallFiles 之后,execute=deferred,impersonate=no 或 4) 在 InstallFinalize 之前安排它它因 .inf 文件的“找不到文件”而失败。
我已经阅读了This SO post和this page,但仍然不明白我是如何安装我的驱动程序的。
如果我在 InstallFinalize 之后使用,那么如果由于其他原因返回错误,则中止安装为时已晚,并且安装失败。