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,因为自定义操作是延迟的.
这本来可以解决这个问题:
<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="MyActionsName.CustomActionData"
Property="MyActionsName" <!-- this is important -->
Value="INSTALLFOLDER=[I_Can_Get_This_From_The_Directory_Tags];SOURCEDIR=[SOURCEDIR];ORIGINALDATABASE=[OriginalDatabase]"/>
<InstallExecuteSequence>
<Custom Action="MyActionsName.CustomActionData" Before="MyActionsName" />
<Custom Action="MyActionsName" Before="InstallFinalize">NOT Installed AND NOT PATCH</Custom>
</InstallExecuteSequence>
Run Code Online (Sandbox Code Playgroud)
在自定义操作中,您可以通过 session.CustomActionData["propertyname"] 访问 MyActionsName.CustomActionData 中的数据集
一般来说,您必须将要在“正常”安装中使用的每个变量/属性显式传递给延迟的自定义操作,以显示在 CustomActionData 中。
我刚刚发现我来晚了。但也许其他人会发现这很有帮助。
| 归档时间: |
|
| 查看次数: |
783 次 |
| 最近记录: |