I thought I was going crazy.. I’d built an installer using WiX and set the product version to 1.0.0.1. The plan was that installing a new version would automatically uninstall any old versions.

I then updated the version to 1.0.0.2 and installed the new version, only to end up with two installations.

Turns out that Windows Installer only looks at the first 3 digits of the ProductVersion (as the first Note mentions in the Windows Installer documentation on Major Upgrades) – so twiddling that 4th digit is not going to have any effect.

Here’s a sample .wxs file that works for me:

<?xml version=”1.0” encoding=”UTF-8”?>

<Wix xmlns=“http://schemas.microsoft.com/wix/2006/wi” xmlns:util=“http://schemas.microsoft.com/wix/UtilExtension”>

<?define version = “1.1.3.11” ?>

<Product Id=”*” Name=“WixUpgrading $(var.version)” Language=“1033” Version=”$(var.version)” Manufacturer=“WixUpgrading”

       UpgradeCode\="630aaa2d-a583-46db-85c4-eaf237590c61"\>

    <Package InstallerVersion\="200" Compressed\="yes" />

    <Media Id\="1" Cabinet\="WixUpgrading.cab" EmbedCab\="yes" />

    <Directory Id\="TARGETDIR" Name\="SourceDir"\>

        <Directory Id\="ProgramFilesFolder"\>

            <Directory Id\="INSTALLLOCATION" Name\="WixUpgrading"\>

                 <Component Id\="ProductComponent" Guid\="c768bc29-e2d6-4f1c-b711-2dcf91641fab"\>

         <File Id\="TextFile1.txt" Name\="TextFile1.txt" KeyPath\="yes" Source\="TextFile1.txt" />

       </Component\>

            </Directory\>

        </Directory\>

    </Directory\>

    <Feature Id\="ProductFeature" Title\="WixUpgrading" Level\="1"\>

        <ComponentRef Id\="ProductComponent" />

    </Feature\>

<Property Id\="PREVIOUSVERSIONSINSTALLED" Secure\="yes" />

<Property Id\="ALLUSERS" Value\="1" />

<Upgrade Id\="630aaa2d-a583-46db-85c4-eaf237590c61"\>

  <UpgradeVersion Property\='PREVIOUSVERSIONSINSTALLED' OnlyDetect\="no" IncludeMinimum\='yes' Minimum\='0.0.0' IncludeMaximum\='no' Maximum\='$(var.version)' />

  <UpgradeVersion Minimum\="$(var.version)" IncludeMinimum\="no" OnlyDetect\="yes" Language\="1033" Property\="NEWERPRODUCTFOUND" />

</Upgrade\>

<InstallExecuteSequence\>

  <Custom Action\="PreventDowngrading" After\="FindRelatedProducts"\>NEWERPRODUCTFOUND AND NOT Installed</Custom\>

  <RemoveExistingProducts Before\='InstallInitialize' />

</InstallExecuteSequence\>

<CustomAction Id\="PreventDowngrading" Error\="Newer version already installed." />

<CustomAction Id\="UIandAdvertised" Error\="Something about the UI."/>

<InstallUISequence\>

  <Custom Action\="UIandAdvertised" Sequence\="3"\>ProductState=1</Custom\>

</InstallUISequence\>

</Product>

</Wix>