0

I have installer for my C# application , Install and uninstall works fine when there are no additional files/logs created while running utility .

But when logs are generated , uninstall doesnot remove the directory and the logs . I tried using RemoveFolderEx Element (Util Extension) , but I do not have component Id for the output folder in which logs are saved as it is created on runtime.

How can I remove output folder so that uninstall goes clean, without leaving files and folders

  • Will you always know the name of the log file in question? And where do you log? I assume you create a sub folder and log there? If so you need a CreateFolder entry to create that logging folder on install and a RemoveFile entry to delete the log file on uninstall. For the record logging in your installation folder is not according to Microsoft logo requirements. – Stein Åsmul Apr 16 '18 at 02:26
  • Yes , I know the names of the log files and also create a sub folder in installation folder and log the files there. – NEHA KHANDELWAL Apr 16 '18 at 04:23
  • also to add , I do not see any CreateFolder entry to create that logging folder on install but still I can see output folder being created and files are logged in the folder – NEHA KHANDELWAL Apr 16 '18 at 04:24

1 Answers1

0

This is a little rushed. I will check back if it makes sense to you.

You should be able to use the standard and built-in RemoveFile feature in MSI to remove log files - if you know the name of the files in question. Then you can add a CreateFolder entry to your installer which creates the logging directory in question and then use that directory property in your RemoveFile entry:

Sample from github:

<Component>
  <File Source="WiX.chm" />
  <Shortcut Id="WixChmShortcut" Directory="ShortcutFolder" Name="WiX Documentation" 
            Icon="WixSetupIcons.ico" IconIndex="0" Advertise="yes" />

  <RemoveFile Id="RemoveWixChw" Name="WiX.chw" On="uninstall" />
</Component>

CreateFolder is a WiX element that you insert to indicate that an empty folder should be created as part of your installation:

   <Directory Id="Mydir" Name="My Directory">
      <Component Feature="MyFeature" >
        <CreateFolder />
        <File Id="NOTEPAD.EXE" Source="$(var.MyReleasePath)\Main Folder\NOTEPAD.EXE" />
      </Component>
   </Directory>

Some further thoughts:

  • I would not do logging in the installation folder - this folder is supposed to be read-only.

  • I would log elsewhere, somewhere in the UserProfile perhaps, or even the temp folder (and let it be cleaned by whatever mechanism the end users have for that).

  • I would also consider logging to the system's event log instead of to a file, if possible.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164