I have a util: RemoveFolderEx element that I want to run only when the program is uninstalled. I put it inside my own component, and then set a condition on the property regarding its inclusion.
Can someone explain to me why the following does not work?
<Property Id='UNINSTALLMODE' Value="FALSE"></Property>
<DirectoryRef Id="DATADIR">
<Component Id="C.RemoveDataFolder" Guid="myguid" KeyPath="yes">
<util:RemoveFolderEx On="uninstall" Property="DATADIR" ></util:RemoveFolderEx>
<Condition>(UNINSTALLMODE="TRUE")</Condition>
</Component>
</DirectoryRef>
<CustomAction Id="CA.SetUninstallMode" Property="UNINSTALLMODE" Value="TRUE" />
<InstallExecuteSequence>
<Custom Action="CA.SetUninstallMode" Before="WixRemoveFoldersEx" >(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
</InstallExecuteSequence>
I checked the logs and the user action correctly set UNINSTALLMODE to "TRUE" when uninstalling the software. When installing and reinstalling it is "FALSE". I tried a custom action that should be scheduled Before = "WixRemoveFoldersEx" and Before = "CostInitialise", which are related to RemoveFoldersEx.
Any help is much appreciated, it drives me crazy! Nile
EDIT: I updated wix to this
<Property Id='P.INSTALLMODE' Value='0'></Property>
<Property Id='P.UNINSTALLMODE' Value='0'></Property>
<DirectoryRef Id="DATADIR">
<Component Id="C.RemoveDataFolder" Guid="myguid" KeyPath="yes">
<util:RemoveFolderEx On="uninstall" Property="DATADIR" ></util:RemoveFolderEx>
<Condition>(P.INSTALLMODE = 1) OR (P.UNINSTALLMODE = 1)</Condition>
</Component>
</DirectoryRef>
<CustomAction Id="CA.SetInstallModeToTrue" Property="P.INSTALLMODE" Value='1' />
<CustomAction Id="CA.SetUninstallModeToTrue" Property="P.UNINSTALLMODE" Value='1' />
<InstallExecuteSequence>
<RemoveExistingProducts Before="InstallInitialize" />
<Custom Action="CA.SetInstallModeToTrue" Before="ValidateProductID" >(NOT UPGRADINGPRODUCTCODE) AND (NOT PREVIOUSVERSIONSINSTALLED)</Custom>
<Custom Action="CA.SetUninstallModeToTrue" Before="ValidateProductID" >(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
</InstallExecuteSequence>
DATADIR CostInitialize.
, , , , , .
EDIT2: , , removefolderex, . .
<Property Id='P.REMOVEDATAFOLDER' Secure='yes' />
<DirectoryRef Id="DATADIR">
<Component Id="C.RemoveDataFolder" Guid="myguid" KeyPath="yes">
<util:RemoveFolderEx On="uninstall" Property="P.REMOVEDATAFOLDER" />
</Component>
</DirectoryRef>
<CustomAction Id="CA.SetDataFolder" Property="P.REMOVEDATAFOLDER" Value='[DATADIR]' />
<InstallExecuteSequence>
<Custom Action="CA.SetDataFolder" Before="ValidateProductID" >(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
</InstallExecuteSequence>