Home > Mobile >  Why is it possible to install two MSIs with the same upgrade code?
Why is it possible to install two MSIs with the same upgrade code?

Time:12-01

Building MSIs with enter image description here

My question

What is the reason that a MSI file does not replace an existing one upon installation with the same UpgradeCode?

(I've also posted this as a question on the WixSharp GitHub repository)

Update/solution

I've finally managed to solve it. Basically I did the following things:

  1. Removed the version string from my setups name (since MSI seems to also compare then names to check whether an upgrade is possible; only the same name seems to fit)
  2. Changed my version number from 4 to 3 digits, as Christopher pointed out. I.e. I'm now incrementing e.g. "1.0.0" to "1.0.1" etc.
  3. Added this code to my WixSharp ManagedProject instance:
    InstallScope = InstallScope.perMachine,
    MajorUpgradeStrategy = new MajorUpgradeStrategy
    {
        UpgradeVersions = VersionRange.OlderThanThis,
        PreventDowngradingVersions = VersionRange.NewerThanThis,
        NewerProductInstalledErrorMessage = "Newer version already installed.",
        RemoveExistingProductAfter = Step.InstallInitialize
    },
    

After these changes, an upgrade succeeded.

CodePudding user response:

The constraint is ProductCode not UpgradeCode. Only 1 MSI per ProductCode can be installed. Attempting to do so again will be a maintenance operation, small update or minor update.

Many MSI can share an UpgradeCode. (Not a good practice though!) For example it's not required for you to author a Major Upgrade at all.

The usual cause here though is you must change the version number in the first three fields and each install must be in the same context (per-user and per-user or per-machine and per-machine). BTW that's another way to install the same ProductCode twice. One per-user and one per-machine. Again not a good practice.

Good:

1.0.0 → 1.0.1 FindRelated Products in the 1.0.1 MSI will see the 1.0.0 and tell RemoveExistingProducts to remove it.

1.0.0 → 1.0.0 or 1.0.0.0 → 1.0.0.1 Bad. FindRelated will see it as the same version and not remove it.

  • Related