Tom Faust
Tom Faust

Reputation: 1415

Wix doesn't remove its files if I remove mine

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();
    }

Upvotes: 0

Views: 756

Answers (2)

saschabeaumont
saschabeaumont

Reputation: 22406

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.

Upvotes: 1

Stein Åsmul
Stein Åsmul

Reputation: 42126

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).

Upvotes: 0

Related Questions