Remove INSTALLDIR on uninstall?

Apr 20, 2015 at 3:49 PM
Anyone having any issues removing the INSTALLDIR on an uninstall?
For some reason, this does not work for me. The files and subdirectories are removed but not the root INSTALLDIR directory.
I've read some posts on the web saying this might be related to GUIDs not being unique...
Anyone?
Apr 20, 2015 at 4:51 PM
Edited Apr 20, 2015 at 4:52 PM
It appears that simply adding a registry value prevents the INSTALLDIR folder from being removed on an uninstall:
        RegValue savedValue = new RegValue(RegistryHive.LocalMachine, @"SOFTWARE\xxx", "My value", "1");
        wixProject.RegValues = new[] { savedValue };
I'm currently using version 13 ...
Apr 20, 2015 at 6:06 PM
I'm able to confirm the above using the "Persisting AppInfo" Wix# example: the "C:\Program Files (x86)\My Company\My Product" directory does not get removed on uninstall when the NativeSetup() method is called. The ManagedSetup() method however does not have that issue.
Coordinator
Apr 21, 2015 at 10:42 AM
This one deserves a special explanation. MSI/WiX has this ridiculous limitation "Directory/File-less setup is impossible ". Thus Wix# defines a dummy empty directory that is removed immediately after it is created. Though this is a subject of another limitation. Empty Directory element cannot compile unless its component has files (obviously) or has CreateFolder element. Thus Wix# injects this element in the components without files (е.г. dummy directory).

Now, your experiments exposed deficiency in this algorithm as in the "Persisting AppInfo" CreateFolder injected in the component of the RegValue. It is actually valid WiX syntax but it is not what is required and the side effect is that directory staying after uninstall.

I have improved the algorithm and the sample works now as expected: changelist#e2d03004ad95. Though something tells me it is not the last time it is revisited.

Anyway I don't know much about your specific case but most likely the problem is caused by the same algorithm deficiency. You can try and see if the change I made addresses the issue. Alternatively you can remove the offending element ins WxsGenerated event as follows:
document.Root.AllElements("CreateFolder").ToArray().ForEach(e=>e.Remove());