The problem is that my custom uninstallation action runs after the removal of standard install files
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.
Can I make the CleanupAction run before the msi starts removing
installation files
Sure, just schedule it before RemoveFiles
:
<Custom Action="CleanupAction" Before="RemoveFiles">
(REMOVE~="ALL") AND (NOT UPGRADINGPRODUCTCODE)
</Custom>
Edit: I have also improved the custom action condition after Stein ?smul made me aware of it. See his answer for the detailed reasoning.
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.
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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…