Wix 自定义卸载操作 - 如何在 msi 删除文件之前运行 [英] Wix custom uninstallation action - how to run before msi removing files

查看:46
本文介绍了Wix 自定义卸载操作 - 如何在 msi 删除文件之前运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a custom action that adds files to the installation directory. When the program is being uninstalled, another custom action tries to remove those files, so that the installation directory can be deleted.

问题是我的自定义卸载操作在删除标准安装文件后运行,所以安装目录仍然存在,尽管它是空的.

The problem is that my custom uninstallation action runs after the removal of standard install files, so the installation directory is left there, although it's empty.

配置看起来像这样:

<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>

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

Can I make the CleanupAction run before the msi starts removing installation files, so that the custom file is already removed and msi can remove the main installation dir?

推荐答案

问题是我的自定义卸载操作在删除标准安装文件后运行

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

那是因为您在 InstallFiles 之前安排了它,它在 标准InstallExecuteSequence.您还可以在 Orca 或 InstEd 等编辑器中打开您的 MSI 文件,并查看 InstallExecuteSequence 表.按Sequence列排序,查看执行顺序.

That's because you have scheduled it before InstallFiles, which comes after RemoveFiles in a standard InstallExecuteSequence. You can also open your MSI file in an editor like Orca or InstEd and have a look at the InstallExecuteSequence table. Sort it by the Sequence column to see the order of execution.

我可以在 msi 开始删除之前运行 CleanupAction安装文件

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

当然,只需在 RemoveFiles 之前安排它:

Sure, just schedule it before RemoveFiles:

<Custom Action="CleanupAction" Before="RemoveFiles">
    (REMOVE~="ALL") AND (NOT UPGRADINGPRODUCTCODE)
</Custom>

在 Stein Åsmul 告诉我之后,我还改进了自定义操作条件.查看他的回答了解详细推理.

I have also improved the custom action condition after Stein Åsmul made me aware of it. See his answer for the detailed reasoning.

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

In case you don't already know, WiX already has support for removing application-generated files which may be able to replace your custom action. It comes in the form of the RemoveFile and util:RemoveFolderEx elements.

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

In case these don't fulfill your needs, so you still need a custom action, I suggest to add temporary records for the files to be removed to the RemoveFile table at runtime (in an immediate custom action!). This gives you the benefits of using the MSI engine for the actual file removal, i. e. automatic rollback if the user decides to cancel the uninstallation or when an error happens. I have done so in the past (before RemoveFolderEx was invented), so if you need more information, just ask another question.

这篇关于Wix 自定义卸载操作 - 如何在 msi 删除文件之前运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆