WIX (remove all previous versions)

Under "Add or remove programs" i can see five versions:

- ApplicationName v3.0.4.0
- ApplicationName v3.0.4.18
- ApplicationName v3.0.5.27
- ApplicationName v3.0.5.28
- ApplicationName v3.0.5.29

when trying to install ApplicationName v3.0.5.30 all previous versions are NOT deleted. Versions that stays are:

- ApplicationName v3.0.4.0
- ApplicationName v3.0.4.18

I already read all about on How to implement WiX installer upgrade?

Code that i use is:

<Product Id="*"
   UpgradeCode="$(var.UpgradeCode)"
   Version="$(var.Version)"
   Language="1033"
   Name="$(var.ProductDisplayName) (v$(var.Version))"
   Manufacturer="Unknown">
<Package InstallerVersion="380" Compressed="yes"/>
<Media Id="1" Cabinet="IileServer.cab" EmbedCab="yes" />

<Property Id="PREVIOUSVERSIONSINSTALLED" Secure="yes" />
<Upgrade Id="$(var.UpgradeCode)">
  <UpgradeVersion
  Minimum="0.0.0.0" Maximum="99.0.0.0"
  Property="PREVIOUSVERSIONSINSTALLED"
  IncludeMinimum="yes" IncludeMaximum="no" />
</Upgrade>

<InstallExecuteSequence>
  <RemoveExistingProducts Before="InstallInitialize" />
</InstallExecuteSequence> 

What i am doing wrong?

I also tryed to build version v3.0.6.0 and after install i got the same result.

Versions v3.0.5.X was removed
Versions v3.0.4.X was not uninstalled

UpgradeCode is the same for all versions, i looked with Orca image

Last UpgradeCode on image is for version 3.0.6.0


Solution 1:

Ignoring Digits: Extract from the MSI SDK documentation for the ProductVersion property:

"Note that Windows Installer uses only the first three fields of the product version. If you include a fourth field in your product version, the installer ignores the fourth field...At least one of the three fields of ProductVersion must change for an upgrade using the Upgrade table."


In order to get rid of installations in the wild, there are a few approaches.

Uninstall By Product Code: I would just get a list of product codes and uninstall corporate-wide if you are delivering an in-house application: How can I find the product GUID of an installed MSI setup? The list of product codes you assemble can then be passed to msiexec.exe /x {productcode} as explained in section 3 here. Just a simple batch file. Or you can try WMI, or one of the other approaches.

Uninstall By Upgrade Code: You can check if all your setup versions share the same upgrade code by using the code from here: How can I find the Upgrade Code for an installed MSI file? (they probably do). There is even a VBScript version here. Throwing in a link to an answer where I link to several other ways to uninstall, such as by uninstalling all setups that share the same upgrade code. And a direct link to actual code to do so (uninstall by upgrade code).

Uninstall By Product Name: You can uninstall by product name matching as well. Some samples here (VBScript): Is there an alternative to GUID when using msiexec to uninstall an application?. And here is a .NET DTF uninstall function: Uninstalling program (distinctively simplistic, needs tweaking for real-world use).


Some Links:

  • Wix MajorUpgrade will not detect last position of product version
  • http://blog.deploymentengineering.com/2010/08/wix-users-exceeding-version-limits.html (here be exotic workaround)
  • Powershell: Uninstall application by UpgradeCode
  • Wix MajorUpgrade problems (the AllowSameVersionUpgrades WiX concept)