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

查看:212
本文介绍了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.

该配置类似于以下内容:

The config looks similar to this:

<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之前,而InstallFiles

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 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天全站免登陆