Major upgrades with WiX

Written on October 16, 2008

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

I then updated the version to 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=“” xmlns:util=“”>

<?define version = “” ?>

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


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

    <Media Id\="1" Cabinet\="" 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" />





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

        <ComponentRef Id\="ProductComponent" />


<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" />



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

  <RemoveExistingProducts Before\='InstallInitialize' />


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

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


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




Categories: Software