The app I am working on creates a bunch of log files in the installation directory after complete installation. The log file names are unknown at install time as they are created by TextWriterTraceListener which can generate the files with names prefixed by
the random GUIDS.
I would like to remove all these files during uninstall and I have found that it is possible by using RemoveFolderEx element :
Is there a way to achieve the same except of:
1) modifying *.wxs file once it's generated
2) calling custom action that removes all the files
these 2 guys might work, but I am looking for more elegant solution.
Also the app writes some registry info after installation complete and I would like to remove it on uninstall, but preserve in the event of upgrade to the newer version.
Feb 8, 2016 at 11:00 PM
Edited Feb 9, 2016 at 12:06 AM
You can actually use RemoveFolderEx as any of other WiX extension (XML injection will be required). But... I am also for more elegant solution and for me nothing bits the elegancy of the fully featured C# code :)
project.AfterInstall += project_AfterInstall;
static void project_AfterInstall(SetupEventArgs e)
var logFiles = Directory.GetFiles(e.InstallDir, "*.log", SearchOption.AllDirectories);
foreach (var item in logFiles)
if(e.Data["UPGRADINGPRODUCTCODE"].IsEmpty()) //only set if triggered by upgrade
You will need just add error handling and that is it. Note that
runs elevated so there will be no problems with the read-write access.