I wanted WiX to remove the AppData folder when uninstalling, so I looked at RemoveFolderEx and followed a few posts/guides on how to get it working. As far as i can tell, my implementation should work, but it does not. I'm using the following:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="AppDataFolder">
<Directory Id="PRIVATEDATAFOLDER" Name="MyApp"/>
</Directory>
</Directory>
<Property Id="PRIVATEDATAFOLDER">
<RegistrySearch Root="HKCU" Key="Software\AppCo\MyApp" Type="raw"
Id="APPLICATIONFOLDER_REGSEARCH" Name="PrivateDir" />
</Property>
<DirectoryRef Id='PRIVATEDATAFOLDER'>
<Component Id="PrivateData" Guid="myGuid">
<CreateFolder Directory="PRIVATEDATAFOLDER"/>
<util:RemoveFolderEx Property="PRIVATEDATAFOLDER" On="uninstall"/>
<RemoveFolder Id="PRIVATEDATAFOLDER" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\AppCo\MyApp" Name="PrivateDir"
Type="string" Value="[PRIVATEDATAFOLDER]" KeyPath="yes"/>
</Component>
</DirectoryRef>
Is there something I'm doing wrong here?
EDIT: After checking a verbose log I get the error:
WixRemoveFoldersEx: Error 0x80070057: Missing folder property: PRIVATEDATAFOLDER