4

I have a C# project with a WiX installer.

When I install my application, all is working. I Have :

  • my compagny folder in program files (x86), containing my application folder and the drivers folder.
  • the shortcut in desktop
  • the shortcut in start menu

When application is installed, I can run my msi and I have an option to uninstall. But when I uninstall my application, only the drivers folder is removed (MyApplication_Drivers). I still have my application folder and the shortcuts.

What I'm missing ?

There is my code for product.wxs (entire code cause I don't know where the problem come from):

<?xml version="1.0" encoding="UTF-8"?>
<?define compagny = "My compagny"?>
<?define product = "MyApplication"?>
<?define version = "!(bind.FileVersion.MyApplication.exe)"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*"
           Name="$(var.product)"
           Language="1033"
           Version="$(var.version)"
           Manufacturer="$(var.compagny)"
           UpgradeCode="***">
        <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="$(var.product)" Level="1">
      <ComponentGroupRef Id="ProductComponents"/>
      <ComponentRef Id ="InstallFonts" />
      <ComponentRef Id ="ApplicationShortcut"/>
      <ComponentRef Id ="ApplicationShortcutDesk"/>
    </Feature>

    <Property Id="WIXUI_INSTALLDIR" Value="COMPAGNYFOLDER"/>    

    <WixVariable Id="WixUIBannerBmp"
                 Value=".\Images\WixUIBannerBmp.bmp"/>
    <WixVariable Id="WixUIDialogBmp"
                 Value=".\Images\WixUIDialogBmp.bmp"/>

    <UI>
      <UIRef Id="WixUI_Custom"/>      

      <Publish Dialog="WelcomeDlg"
               Control="Next"
               Event="NewDialog"
               Value="InstallDirDlg"
               Order="2">1</Publish>

      <Publish Dialog="InstallDirDlg"
               Control="Back"
               Event="NewDialog"
               Value="WelcomeDlg"
               Order="2">1</Publish>
    </UI>
    </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="FontsFolder" />

      <Directory Id="ProgramMenuFolder">
        <Directory Id="ApplicationProgramsFolder" Name="$(var.compagny)"/>
      </Directory>

      <Directory Id="DesktopFolder" SourceName="Desktop"/>

      <Directory Id="ProgramFilesFolder">
        <Directory Id="COMPAGNYFOLDER" Name="$(var.compagny)">
          <Directory Id="INSTALLFOLDER" Name="$(var.product)">
            <Directory Id="fr" Name="fr"/>
            <Directory Id="SETTINGS" Name="Settings">
              <Directory Id="PRINTERS" Name="Printers"/>
            </Directory>
          </Directory>
          <Directory Id="Drivers" Name="MyApplication_Drivers"/>
        </Directory>
      </Directory>
    </Directory>
  </Fragment>

  <Fragment>
    <DirectoryRef Id="ApplicationProgramsFolder">
      <Component Id="ApplicationShortcut" Guid="***">
        <Shortcut Id="ApplicationStartMenuShortcut"
                  Name="$(var.product)"
                  Description="$(var.product) application"
                  Target="[#MyApplication.exe]"
                  WorkingDirectory="INSTALLFOLDER"/>
        <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
        <RegistryValue Root="HKCU" Key="SOFTWARE\$(var.compagny)\$(var.product)" Name="installedStart" Type="integer" Value="1" KeyPath="yes"/>
      </Component>
    </DirectoryRef>

    <DirectoryRef Id="DesktopFolder">
      <Component Id="ApplicationShortcutDesk" Guid="***">
        <Shortcut Id="ApplicationStartDeskShortcut"
                  Name="$(var.product)"
                  Description="$(var.product) application"
                  Target="[#MyApplication.exe]"
                  WorkingDirectory="INSTALLFOLDER"/>
        <RemoveFolder Id="DesktopFolder" On="uninstall"/>
        <RegistryValue Root="HKCU" Key="SOFTWARE\$(var.compagny)\$(var.product)" Name="installedDesk" Type="integer" Value="1" KeyPath="yes"/>
      </Component>
    </DirectoryRef>

    <DirectoryRef Id="FontsFolder">
      <Component Id="InstallFonts" Guid="{***}" Permanent="yes">
        <File Id="OCRB_Medium.ttf" Source="$(var.SolutionDir)_Required\OCRB_Medium.ttf" TrueType="yes" />
        <File Id="OCRBS___.TTF" Source="$(var.SolutionDir)_Required\OCRBS___.TTF" TrueType="yes" />
      </Component>
    </DirectoryRef>
  </Fragment>

    <Fragment>
    <ComponentGroup Id="ProductComponents">
      <!-- Application -->
      <Component Id="ProductComponent" Guid="{***}" Directory="INSTALLFOLDER" UninstallWhenSuperseded="yes">
        <!-- DLL -->
        <File Id="Bitmap.Core.dll" Source="$(var._Delivery.TargetDir)..\bin\Bitmap.Core.dll"/>
        <File Id="PdfLib.dll" Source="$(var._Delivery.TargetDir)..\bin\PdfLib.dll"/>

        <!-- EXE -->
        <File Id="MyApplication.exe" Source="$(var._Delivery.TargetDir)..\bin\MyApplication.exe"/>
        <File Id="MyApplication.exe.config" Source="$(var._Delivery.TargetDir)..\bin\MyApplication.exe.config"/>
      </Component>

      <!-- fr -->
      <Component Id="FRComponent" Guid="{***}" Directory="fr" UninstallWhenSuperseded="yes">
        <File Id="resources-fr.dll" Source="$(var._Delivery.TargetDir)..\bin\fr\resources-fr.dll" />
      </Component>

      <!-- Settings -->
      <Component Id="SetComponent" Guid="{***}" Directory="SETTINGS" UninstallWhenSuperseded="yes">
        <File Id="Settings.xml" Source="$(var.MyApplication.ProjectDir)Settings\Settings.xml" />
      </Component>

      <!-- Printers -->
      <Component Id="PrintComponent" Guid="{***}" Directory="PRINTERS" UninstallWhenSuperseded="yes">
        <File Id="Sticker.xml" Source="$(var.MyApplication.ProjectDir)Settings\Printers\Sticker.xml" />
      </Component>

      <!-- Resources -->
      <Component Id="Drivers" Guid="{***}" Directory="Drivers" UninstallWhenSuperseded="yes">
        <File Id="drivers.exe" Source="$(var.SolutionDir)_Required\drivers.exe"/>
        <File Id="user_manual_E.pdf" Source="$(var.SolutionDir)_Required\user_manual_E.pdf"/>
      </Component>
        </ComponentGroup>
    </Fragment>
</Wix>

EDIT :

  • An old version of this code was perfectly working

  • I printed log while uninstall and this line seems to be related to this problem :

MSI (c) (E8:BC) [10:58:16:769]: Disallowing uninstallation of component: {one of my guids} since another client exists

A.Pissicat
  • 3,023
  • 4
  • 38
  • 93

2 Answers2

3

WiX won't uninstall components it thinks are already installed, which I assume is the case here. Why?

  • Could be reuse of guids (make sure they are all unique)
  • Could be an earlier version of this installer marked those components as permanent at one point

However, what sets your code apart from similar questions I've seen on this issue is that you don't have any File elements listed as the KeyPath to your component. Therefore, I believe the parent directory becomes the KeyPath by default. The KeyPath is used to determine whether or not a component is installed on the machine. If they KeyPath is set to the directory, and the directory already existed, then likely it won't get removed on uninstall, since it was already installed.

As a best practice, try to have a single File in each Component, and in the File element set KeyPath="yes".

Similar questions on this topic:

BryanJ
  • 8,485
  • 1
  • 42
  • 61
  • I've seen some of these topic before, but issue does't work for me. After some research it seems that my problem was very simple (I'll add the answer) – A.Pissicat Sep 13 '17 at 11:01
2

I finally found what was going on. My install was working, I installed the application application on my computer.

Recently, I modified the name of my Drivers directory (not the Id). I have re installed my application (without removing older) and install was OK. After that, the problem did appear.

Solution was simple :

  • removing my application with Windows menu (2 applications was installed)

Now install/uninstall is perfectly working.

A.Pissicat
  • 3,023
  • 4
  • 38
  • 93