WIX Custom Action - run at different times for install, upgrade and uninstall
I have a custom action that removes various directories as part of the uninstall process. I want to call this action at different points in the install sequence depending on what's being done:
- During an install, don't run the custom action
- During an upgrade, run the custom action after RemoveExistingProducts
- During an uninstall, run the custom action after RemoveFolders
I can likely get each one of these to work individually, but how do I get them to work together how I want. I tried something like this (some code take from here):
<InstallExecuteSequence>
<Custom Action="PreventDowngrading" After="FindRelatedProducts">
NEWERPRODUCTFOUND AND NOT Installed
</Custom>
<LaunchConditions After="AppSearch" />
<RemoveExistingProducts Before="InstallInitialize" />
<!-- NEW _> Clean old files AF开发者_运维知识库TER uninstall during an upgrade -->
<Custom Action="CleanUp" After="RemoveExistingProducts" >
UPGRADINGPRODUCTCODE
</Custom>
<!-- NEW _> Clean old files LAST during an uninstall -->
<Custom Action="CleanUp" After="RemoveFolders" >
(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
</Custom>
</InstallExecuteSequence>
But get a duplicate symbol error when I do a build. Any help will be greatly appreciated!
You can also use RemoveFiles to get rid of the extraneous files in a directory.
A custom action can be in a sequence only once. I have some bigger concerns though: what type of upgrade are you doing? A major upgrade does a uninstall of the previous product so your CA might run twice the way you are describing it.
I would tread really lightly here. Can you possibly use the WiX RemoveFolder element ( MSI RemoveFile table ). This will be alot easier and reliable to implement. If you must use a custom action I would use component action states to determine when it should run rather then more generic properties like shown above.
精彩评论