gpt4 book ai didi

installation - Wix 自定义卸载操作 - 如何在 msi 删除文件之前运行

转载 作者:行者123 更新时间:2023-12-01 07:33:30 25 4
gpt4 key购买 nike

我有一个将文件添加到安装目录的自定义操作。卸载程序时,另一个自定义操作会尝试删除这些文件,以便删除安装目录。

问题是我的自定义卸载操作在删除标准安装文件后运行,因此安装目录保留在那里,尽管它是空的。

配置看起来类似于:

<CustomAction Id="AddFilesAction" BinaryKey="installerActions" DllEntry="AddFiles" Execute="deferred" Return="check" Impersonate="no" />
<CustomAction Id="CleanupAction" BinaryKey="installerActions" DllEntry="Cleanup" Execute="deferred" Return="check" Impersonate="no" />

<InstallExecuteSequence>
<Custom Action="CleanupAction" Before="InstallFiles">Installed</Custom>
<Custom Action="AddFilesAction" After="InstallFiles">NOT Installed</Custom>
</InstallExecuteSequence>

我可以制作 CleanupAction在 msi 开始删除安装文件之前运行,以便自定义文件已经被删除并且 msi 可以删除主安装目录?

最佳答案

The problem is that my custom uninstallation action runs after the removal of standard install files



那是因为你之前已经安排好了 InstallFiles , 在 RemoveFiles 之后在 standard InstallExecuteSequence .您还可以在 Orca 或 InstEd 等编辑器中打开您的 MSI 文件并查看 InstallExecuteSequence table 。按 Sequence 排序列以查看执行顺序。

Can I make the CleanupAction run before the msi starts removing installation files



当然,只需在 RemoveFiles 之前安排它:
<Custom Action="CleanupAction" Before="RemoveFiles">
(REMOVE~="ALL") AND (NOT UPGRADINGPRODUCTCODE)
</Custom>

编辑:在 Stein Åsmul 提醒我之后,我还改进了自定义 Action 条件。 See his answer详细的推理。

如果您还不知道,WiX 已经支持删除应用程序生成的文件,这些文件可能能够替换您的自定义操作。它以 RemoveFile 的形式出现和 util:RemoveFolderEx 元素。

如果这些不能满足您的需求,因此您仍然需要自定义操作,我建议将要删除的文件的临时记录添加到 RemoveFile运行时的表(立即自定义操作!)。这为您提供了使用 MSI 引擎进行实际文件删除的好处,即。 e.如果用户决定取消卸载或发生错误,则自动回滚。我过去曾这样做过(在 RemoveFolderEx 发明之前),所以如果您需要更多信息,请再问一个问题。

关于installation - Wix 自定义卸载操作 - 如何在 msi 删除文件之前运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50912568/

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