Majorupgrade or Upgrade ID which is preferred for Major upgrade?
Asked Answered
O

1

12

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?

Outtalk answered 14/6, 2012 at 6:2 Comment(1)
Schedule has the option "afterInstallValidate" which is before InstallInitialize.Different
A
25

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.

Adventitia answered 14/6, 2012 at 7:49 Comment(1)
I needed a feature not available with MajorUpgrade (i.e., allow major upgrade from old versions but not from very old versions), so your answer was extremely useful in "converting" MajorUpgrade to the equivalent (and more customizable) "old-style" code. Thanks!Toga

© 2022 - 2024 — McMap. All rights reserved.