Wix - how to delete a non-empty folder

I read all the topics on this site with such a problem, but did not find what I need.

I have two versions of one program: old and new. In the old version, I have a folder f1. In the new version, I do not have this folder f1.

When the installer of a new program finds an old version, it deletes that old version, but not the f1 folder.

How to remove f1 from the installer of the new version?

<Component Id ="deleteall" Guid="AA11A32B-9E1E-458A-8C94-3EFEDA77E494" > <RemoveFolder Id='iDocDir' On='both' /> </Component> <Directory Id="iDocDir" Name="iDocs"> </Directory> 

does not work = (

+6
source share
1 answer

You should check the RemoveFolderEx element in UtilExtension . He does exactly what you want. Bob Arnson reported this earlier.

 <Component Id="deeletall" Guid="PUT-GUID-HERE"> <util:RemoveFolderEx Id="RemoveiDocDir" On="uninstall" Property="iDocDir" /> </Component> 

It works by writing temporary lines to the RemoveFile table. However, there are restrictions on the use of this, as indicated in the manual:

Since this can significantly affect the Windows Installer File Costing, temporary lines must be written before the standard CostInitialize action. Unfortunately, MSI does not create properties for the Directory Hierarchy in your package until a later time in the CostFinalize action file.

An easy workaround for a typical case of using a folder during delete is to write the directory path to the registry and load it during removal.

If you use custom actions to set properties, make sure they are scheduled before the custom WixRemoveFoldersEx action.

And also in Bob's post:

How to add directories and files to be deleted affects the MSI Costing file; RemoveFolderEx must do its job before costing. Unfortunately, MSI does not configure properties for target directories until the cost is complete.

If you have already saved your previous installation path (Rob explains how to do it here ) in the registry, everything is fine, as the AppSearch action runs before CostInitialize.

+11
source

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


All Articles