Skip to main content

Replacing Ourselves

...

If our intention is a major upgrade, that is, complete and automatic removal of the previous version when a new one arrives, we just need to set OnlyDetect to no and to set the version numbers accordingly. Minimum will then specify the first version we allow to replace with the current one (and we include this minimum version in the range) while Maximum can be set to the current version number (but not included in the range). Then, any version between the first and the previous one before the current version will be removed automatically during the installation of the current version. Also note that this same installer works as a first time installer as well: if it founds a previous version, it will remove the previous version and install the current one. If it is run on a clean system, it will simply install the current application; there is no need to create separate upgrade and full installers.

<Upgrade Id='YOURGUID-7349-453F-94F6-BCB5110BA4FD'>
  <UpgradeVersion OnlyDetect='no' Property='PREVIOUSFOUND'
    Minimum='1.0.0' IncludeMinimum='yes'
    Maximum='3.0.0' IncludeMaximum='no' />
</Upgrade>

The removal of the previous version is completely automatic. If, for any reason, we need to perform any action when this previous version is removed, we can author a custom action whose condition is the UPGRADINGPRODUCTCODE property. The Windows Installer only sets this property when the automatic removal is in progress, not when the application is manually uninstalled using Add and Remove Programs.

<InstallExecuteSequence>
  <Custom Action=' ... ' After=' ... '>UPGRADINGPRODUCTCODE</Custom>
  <RemoveExistingProducts Before="InstallInitialize" />
</InstallExecuteSequence>

Note that both Upgrade and UpgradeVersion only work if you are doing a major upgrade.

Unclear

Already this entire tutorial is hard to follow - a lot of things left unclear.  But this page is the worst.
<Custom Action=' ... ' After=' ... '>UPGRADINGPRODUCTCODE</Custom>
 
REALLY?  That's it?  This does not work and you give no clues as to what needs to be put here.  That tag doesn't make it past light command, and trying to figure out what to put there takes far too long given that this is a tutorial.
 
Just some constructive criticism - don't leave things out that break compile. 

Upgrade works only in major upgrade

Hi!
Here you say: "Note that both Upgrade and UpgradeVersion only work if you are doing a major upgrade."
But in the previous section:
"Upgrade tag refers back to the UpgradeCode GUID of the original installation package (the older Samp
leUpgrade in our case). The internal UpgradeVersion tag describes the details of the versions to be updated. OnlyDetect tells the installer not to remove the previous product (remember, we're doing a minor upgrade"
Some inconsistent statements

Agreed - what's going on in

Agreed - what's going on in this section?

Nothing else but WiX itself

Nothing else but WiX itself being a slowly moving target, subject to modifications and improvements over time. What's written there was certainly valid when written but the tools seem to have been changed in this area. I'll try to find time to brush this section up but if you happen to find the culprit and the correct behavior, please do mention it here. It's a collaborative effort, you know... :-)