3

I have created a my first Wix Setup to my C# project (i'm beginner with wix).

The setup create a msi file, this file works good. After setup all DLL and .exe are created in "C:\Program Files (x86)\MyApplication"

But when I right click on msi and select uninstall, a uninstall menu is displayed without error but folder "C:\Program Files (x86)\MyApplication" is not removed.

How can I define uninstall function to remove this folder ?

There is a part of my Product.wxs

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <Product Id="*"
           Name="My Application"
           Language="1033"
           Version="1.0.0.0"
           Manufacturer="Me"
           UpgradeCode="36944ae1-9e9f-4ef0-a860-9d894e0c28ef">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"/>
    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed."/>
    <Media Id="1" Cabinet="myApplication.cab" EmbedCab="yes"/>

    <Feature Id="ProductFeature" Title="My Application" Level="1">
      <ComponentGroupRef Id="ProductComponents"/>
      <ComponentRef Id ="ApplicationShortcut"/>
      <ComponentRef Id ="ApplicationShortcutDesk"/>
      <ComponentRef Id ="RemoveAll"/>
    </Feature>
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramMenuFolder">
        <Directory Id="ApplicationProgramsFolder" Name="My Application"/>
      </Directory>
      <Directory Id="DesktopFolder" SourceName="Desktop"/>
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="My Application">
          <Directory Id="fr" Name="fr"/>

          <Component Id="RemoveAll" Guid="{63F6943C-7707-41CA-BAB9-7438471EC81E}">
            <RemoveFile Id="RemoveAllFilesOnUninstall" Directory="INSTALLFOLDER" Name ="*.*" On ="uninstall"/>
            <RemoveFolder Id="RemoveAllFoldersOnUninstall" Directory="INSTALLFOLDER" On="uninstall"/>
            <RegistryValue Root="HKLM" Key="Software\Microsoft\MyApplication" Name="Path" Type="string" Value="[INSTALLFOLDER]" KeyPath="yes" />
            <util:RemoveFolderEx On="uninstall" Property="INSTALLFOLDER" />
          </Component>
        </Directory>
      </Directory>
    </Directory>
  </Fragment>

  <Fragment>
    <DirectoryRef Id="ApplicationProgramsFolder">
      <Component Id="ApplicationShortcut" Guid="{3B0B5064-807C-4E29-A701-E77BE8B8FA86}">
        <Shortcut Id="ApplicationStartMenuShortcut"
                  Name="My Application"
                  Target="[#MyApplication.exe]"
                  WorkingDirectory="INSTALLFOLDER"/>
        <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
        <RegistryValue Root="HKCU" Key="Software\Microsoft\MyApplication" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
      </Component>
    </DirectoryRef>
    <DirectoryRef Id="DesktopFolder">
      <Component Id="ApplicationShortcutDesk" Guid="{61087C99-9CA8-4191-8251-219DFDAFC666}">
        <Shortcut Id="ApplicationStartDeskShortcut"
                  Name="My Application"
                  Target="[#MyApplication.exe]"
                  WorkingDirectory="INSTALLFOLDER"/>
        <RemoveFolder Id="DesktopFolder" On="uninstall"/>
        <RegistryValue Root="HKCU" Key="Software\Microsoft\MyApplication" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
      </Component>
    </DirectoryRef>
  </Fragment>

  <Fragment>
    <ComponentGroup Id="ProductComponents">
      <Component Id="ProductComponent" Guid="{5C62E31A-C787-4B45-A4F7-2324A12C72D1}" Directory="INSTALLFOLDER">
        <!-- List of DLL/EXE -->
    </ComponentGroup>
  </Fragment>
</Wix>

Edit: I'm now using UtilExtension and the INSTALLFOLDER is now correctly deleted. The only elements renaming are the ApplicationShortcutDesk and the ApplicationStartMenuShortcut. How the RemoveFolderworks for a shortcut ?

A.Pissicat
  • 3,023
  • 4
  • 38
  • 93
  • Why do you use custom action for this purpose? When you uninstalIing your product, installer removes all files created by itself. This is default behaviour. Maybe you accidentally used "Permanent" attribute with your "File" tags? – Anton Sutarmin Aug 30 '16 at 11:19
  • 1
    Also, I recommend you to generate log during uninstalling. It is very helpful for problem detection. For this, install your msi as usual and then run `msiexec /x msiname.msi /l*v uninstall.log` for uninstalling. – Anton Sutarmin Aug 30 '16 at 11:26
  • I have try without custom action, nothing is deleted and I have no `Permanent` attribute with file tag. My file tags are all like this `` (I added a log in my question) – A.Pissicat Aug 30 '16 at 11:51
  • Remove custom action from your installer. It may cause side errors which making harder to find out main reason. Also attach please entire log file. It will help to find out why your files doesn't removing in standard way during uninstallation. – Anton Sutarmin Aug 30 '16 at 12:25
  • I finally find a way by using `UtilExtension` (you rigth, custom action was a bad idea). The install folder is now deleted ! I just need to delete the both shortcuts created – A.Pissicat Aug 30 '16 at 12:30
  • 2
    I'll say it one more time. Situation, when installer doesn't remove it's own created files during uninstallation IS NOT NORMAL. May be you might find out the reason of this behaviour... – Anton Sutarmin Aug 30 '16 at 13:35
  • I saw [that post](http://stackoverflow.com/a/7579715/6479770). I tried to change all my GUIDs and remove my component `RemoveAll`. Now all works good. I don't really understand what was the problem, I generated myself all GUIDs this morning and now with the same methods it works. At least thank for your help, I started to be crazy and I've lost an entire day for that – A.Pissicat Aug 30 '16 at 13:54
  • You should not require any ``, ``, ``, or custom actions in such a simple installation. – Brian Sutherland Aug 30 '16 at 14:39

1 Answers1

5

I finally found what was going wrong thanks to Anton Sutamin.

My GUIDs prevented the removal (see on that post)

With new GUIDs, all works good, without CustomAction/RemoveFile/etc...

GuiFalourd
  • 15,523
  • 8
  • 44
  • 71
A.Pissicat
  • 3,023
  • 4
  • 38
  • 93