UnInstall Cleanup

Aug 21, 2015 at 6:36 AM
Hi Oleg;

Good work!
Using WixSharp to build our package

Looking to completely uninstall apps but MSI does leave a logs directory behind as created by the App at runtime;

How can I remove this at Uninstall time?

Thanks in advance
David Tuke
Aug 23, 2015 at 10:53 AM
Hi David,

Thank you. I am glad you like Wix#.

>...MSI does leave a logs directory behind...
This is how MSI works. If you place any file (e.g. log) in the installed app folder this folder will not be deleted during uninstall. The idea behind this is that you are not expected to write anything into these folders. Thus %ProgramFiles% is a "holly cow" and no one, even the installed app, should be writing there. All logs, settings etc. supposed to go to the user profile.

Though if you really need to use a brut force for deleting the folders the you can do this similar to the code below:
var project =
    new ManagedProject(
project.AfterInstall += Project_AfterInstall;
static void Project_AfterInstall(SetupEventArgs e)
    if (e.IsUninstalling)
        string logDir = IO.Path.Combine(e.InstallDir, "Logs");
        IO.Directory.Delete(logDir, recursive: true);