views:

303

answers:

2

I have a Wix installer which installs and removes fine if I don't execute my custom actions. But if I do execute them then my custom action does its job, and the uninstall does succeed, but all of the files installed remain in the program files application directory.

On install, my custom action (After="InstallFiles") extracts a number of files from a Zip into directories under the main install directory. I also capture a list of all files extracted (added). This works perfectly.

On uninstall, my custom action (After="MsiUnpublishAssemblies") runs through the list and removes the added files, added sub-directories and the file list itself. This works fine - my added files are removed. But the primary files originally installed by the installer are left behind even though the installer goes through all the steps (as far as I can tell by the log file) and ends successfully.

Any ideas would be a great help here.

Thanks!

Update: I have tentatively solved this the brute-force way, but I would still like a real answer. Here's my brute-force code. I call it with a DirectoryInfo of my InstallDir.

    private static void CleanupTheRest(DirectoryInfo dirInfo)
    {
        // until I figure out why the unistall won't remove these after executing my CA
        foreach (var subDirInfo in dirInfo.GetDirectories())
        {
            CleanupTheRest(subDirInfo);
        }
        foreach (var file in dirInfo.GetFiles())
        {
            file.Delete();
        }
        dirInfo.Delete();
    }
A: 

The approach you are using to extract files from an embedded zip isn't something I would put into my MSI. Rather I would have the application extract the zip on launch - much more controllable and reliable. Actually I wouldn't recommend any unzipping at all, but sometimes it is necessary for data files.

How have you scheduled your remove operation? Immediate / Deferred? Do you use synchronous or asynchronous running mode? If you comment out your uninstall custom action, does the uninstall work? If you have enabled the "legacy shareddll ref-count" feature, you could have trash reference counts in the registry: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDLLs (if so delete the entries and try again - this may make the uninstall work as expected).

Glytzhkof
We have multiple features each of which need to start with their own copy of a large collection of data files. I'm trying not to put this collection into the installer multiple times. Unzipping works great to get the features installed. To answer your questions:* 'immediate', After MsiUnpublishAssemblies* synchronous (check)* without the "remove" CA the uninstall works but leaves the unzipped files behind* I have not enabled the "legacy shareddll ref-count" featureMaybe I could try generating a fragment component of "RemoveFile" elements for each feature instead.Thanks for responding!
Tom Faust
+1  A: 

Extracting a ZIP really isn't the best way of going about things, that aside however you just need to use the RemoveFile element to have Windows Installer delete the files during uninstallation.

sascha