[wix-users] RemoveFolderEx and disabled components

Paul Shmakov paul.shmakov at gmail.com
Thu Oct 18 16:38:18 PDT 2018


WixRemoveFolderEx searches the file system and populates the
RemoveFile table even for the disabled components. It's a problem
because the path may not exist.

Here's my use case: during the installation I need to delete traces of
the previous version of the product that was installed using batch
files (not MSI), if it's present.

All the cleaning up is packaged as a Component which has a condition
"NOT Installed AND OLDPRODUCTFOUND". The component consists of a bunch
of RemoveFile nodes and RemoveFolderEx to delete certain subfolders.

The RemoveFolderEx here makes sense only if the old product is
detected (OLDPRODUCTFOUND property). Otherwise there's no meaningful
path to search through.

WixRemoveFoldersEx does not check the installation state of the
component, nor does it have its own condition. As a result
WixRemoveFoldersEx always executes and tries to search the path that
does not exist. And fails.

Here's a snippet:
      Path="[ProgramFilesFolder]\Company\Product X"
    <FileSearch Name="ProductX.exe"/>

    Before="CostInitialize" />

<Component Id="CleanupOldProduct">
  <Condition>NOT Installed AND OLDPRODUCTFOUND</Condition>
  <util:RemoveFolderEx Property="OLDSUBFOLDER" On="install"/>

If the old product is not found, WixRemoveFoldersEx tries to enumerate
"\Foo\Bar" and fails.

I'd really appreciate if somebody can explain what I'm doing wrong
here or point me to a known workaround.
The only solution I can think of is to set the property (OLDSUBFOLDER)
to some non-existent folder to let WixRemoveFoldersEx fail gracefully.

Wix 3.11

Thanks in advance,

More information about the wix-users mailing list