Upgrades out of order?

Apr 15, 2015 at 4:30 PM
Edited Apr 15, 2015 at 7:53 PM
It appears that when an upgrade is installed, the newer version is installed fine, but before the older version is uninstalled.
Do you know if this is normal behavior of MSI's? Shouldn't it be that the older version is uninstalled first before the newer version is applied?
This is causing an issue for me where I'm calling some custom code (using InstalledFileAction) to install a service, and the service is removed after it is installed...
Apr 15, 2015 at 8:01 PM
If the above is per design, is there any way we can combine something like:

wixProject.MajorUpgradeStrategy = new MajorUpgradeStrategy
{
UpgradeVersions = VersionRange.ThisAndOlder + VersionRange.ThisAndNewer,
PreventDowngradingVersions = VersionRange.None
}

Thanks,

Jean-Marc
Coordinator
Apr 16, 2015 at 7:04 AM
You can set the desired step to any value as follows:
project.MajorUpgradeStrategy = MajorUpgradeStrategy.Default;
project.MajorUpgradeStrategy.RemoveExistingProductAfter = Step.InstallInitialize;  
Apr 16, 2015 at 7:16 PM
Works great, thanks!
I still haven't figured out how to do UpgradeVersions = VersionRange.ThisAndOlder + VersionRange.ThisAndNewer (i.e. same code that will work for both upgrades and downgrades), but I guess we can always uninstall, before reinstalling...
Coordinator
Apr 17, 2015 at 1:05 AM
Actually VersionRange.NewerThanThis is not a magic constant but a predefined object, which you can define by yourself :)
UpgradeVersions = new VersionRange
                  {
                      Minimum = "0.0.0.0",
                      Maximum = "99.99.99.99",
                      IncludeMinimum = true,
                      IncludeMaximum = true,
                  };
I haven't tried it so there may be some other hiccups.
Apr 17, 2015 at 1:52 PM
Sweet it works!

This is what I have done:
        VersionRange upgradeVersions = new VersionRange
        {
            Minimum = "0.0.0.0",
            Maximum = "99.99.99.99",
            IncludeMinimum = true,
            IncludeMaximum = true,
        };

        VersionRange downgradeVersions = new VersionRange
        {
            Minimum = "99.99.99.99",
            Maximum = "0.0.0.0",
            IncludeMinimum = true,
            IncludeMaximum = true,
        };

        wixProject.MajorUpgradeStrategy = new MajorUpgradeStrategy
        {
            UpgradeVersions = upgradeVersions,
            PreventDowngradingVersions = downgradeVersions,
            NewerProductInstalledErrorMessage = "Newer version already installed"
        };

        wixProject.MajorUpgradeStrategy.RemoveExistingProductAfter = Step.InstallInitialize;
... with this every install will remove any other version of the software before reinstalling (although I have not yet tested minor revisions) whether if it is older or newer.
Something to note is that the "NewerProductInstalledErrorMessage = "Newer version already installed"" property is required even though it does not apply in this case.
If not specified, you get a compile error.

Keep up the good work Oleg!