wixwindows-installermajor-upgrade

Majorupgrade or Upgrade ID which is preferred for Major upgrade?


We are trying to do Major upgrade. While i was investigating i found 2 approaches.

One is using Upgrade Id and another one approach was Majorupgrade tag.

It seems Majorupgrade is easy to do it seems. But schedule doesn't contain any before installinitialize action.

I am not sure which should be using .

Which one is preferred [and recommended] mostly?


Solution

  • The MajorUpgrade element was introduced in wix 3.5 to simplify what you would normally do with the Upgrade element. So that instead of something like this:

    <!– Major upgrade –> 
    <Upgrade Id="$(var.UpgradeCode)"> 
        <UpgradeVersion Minimum="$(var.ProductVersion)" OnlyDetect="yes" Property="NEWERVERSIONDETECTED" /> 
        <UpgradeVersion Minimum="1.0.0" IncludeMinimum="yes" Maximum="$(var.ProductVersion)" IncludeMaximum="no" Property="OLDERVERSIONBEINGUPGRADED" /> 
    </Upgrade>
    
    <InstallExecuteSequence> 
        <RemoveExistingProducts After="InstallValidate" /> 
    </InstallExecuteSequence>
    
    <Condition Message="Can't downgrade"> 
        NOT NEWERVERSIONDETECTED 
    </Condition>
    

    You can simply do this:

    <MajorUpgrade DowngradeErrorMessage="Can’t downgrade." />
    

    Not only is the old way more verbose, it also requires that you repeat the upgrade code and product version which are specified in the Product element. So the sample above has to make use of wix variables to keep them in sync. If you get that wrong, the upgrade won't work correctly.

    The new MajorUpgrade element has none of those complications, so I recommend that you use it. See also this blog post by Bob Arnson introducing MajorUpgrade and the topic in the wix documentation on the subject.