Removing application use(r)-generated files with WiX
-
12-06-2021 - |
Question
Currently, our user data hierarchy looks like this:
LocalAppDataFolder/Company/Product
This makes sense as far as it goes because a user might have multiple products installed. However, WiX will not let me remove just the Product folder.
<Directory Id="LocalAppDataFolder">
<Directory Id="ManufacturerDir" Name="Company">
<Directory Id="AppDataDir" Name="Product">
<Component Id="AppData" Guid="some_guid">
<RemoveFolder Id="AppDataDir" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\Company\Product" Type="string" Value="" />
</Component>
</Directory>
</Directory>
</Directory>
The above snippet causes the error, "LGHT0204 : ICE64: The directory Company is in the user profile but is not listed in the RemoveFile table." Obviously, I don't want to wipe the data from other products. Several examples that I've found are only one directory deep, i.e. they do not include an intervening directory, in this case Company.
I get the feeling that I am misunderstanding something here. What? Many thanks.
Solution
Adding <RemoveFolder Id="RemoveManufacturerDir" Directory="ManufacturerDir" On="Uninstall"/>
should get rid of that error. The folder will only get removed if the directory is empty. If there are other files in there, it will not be removed.