Wix: Can I put a condition on the RemoveFolderEx element only to run when the program is uninstalled?

I am trying to remove the folder hierarchy using RemoveFolderEx, but only when uninstalling the software. Currently, when I do the reinstallation, it also deletes all folders that delete all unwanted files created by the program. This is probably due to the fact that I installed that the software will be removed before reinstalling it.

<InstallExecuteSequence> <RemoveExistingProducts Before="InstallInitialize" /> </InstallExecuteSequence> 

Is it possible to impose a condition on the next element? Should I wrap it in my own component and then add the condition inside? I could not get it to work so far.

 <util:RemoveFolderEx On="uninstall" Property="MAINDIR" ></util:RemoveFolderEx> 

From another question that I know should be

 ((NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")) 

but I'm not quite 100% on how to apply this to the removefolder element, if possible.

I assume that I can set the folder path to empty in a user action that was subject to a condition, but that just seems to be hacked.

Greetings. Nile


EDIT: I almost got this working by putting removefolderex into my own component. Without a condition, it works as expected and deletes the data directory upon uninstallation and reinstallation. When I add a condition in it, it does not start, but I hope that it is not the way it would be wrong.

 <DirectoryRef Id="DATADIR"> <Component Id="C.RemoveDataFolder" Guid="myguid" KeyPath="yes"> <util:RemoveFolderEx On="uninstall" Property="DATADIR" ></util:RemoveFolderEx> <Condition>(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Condition> </Component> </DirectoryRef> 

Does anyone know if the above expression supports or it will never work? Can I apply this condition to a component?

+4
source share
2 answers

RemoveFolderEx is bound to the component, so if it is removed and RemoveFolderEx / @ On = "uninstall", then RemoveFolderEx will do its job. There is no support for adding another condition, but this seems reasonable; please write a function request so that it appears in the task list.

+4
source

The component condition determines whether the component is installed. This condition is incorrect during installation; therefore, the component is not installed. Naturally, when deleting it is not deleted, so the delete operation does not work. I would go with a custom action that conditionally sets the target property.

0
source

Source: https://habr.com/ru/post/1382745/


All Articles