Force uninstall before installing any version using the wix installer

Somebody knows:

  • How can I get the wix installer to delete a previous previously installed copy, whether small or large, before installing a new version of our installation.

  • If 1) cannot be performed when starting a new small / main setup, can I at least display a message stating that a previous version was found, and I need to delete it and cancel the setup first?

Thanks.

UPDATE:

I added the following to my settings. wxi

<Upgrade Id="$(var.UpgradeCode)"> <!-- Populate NEWERPRODUCTFOUND if there is an installed package with the same upgrade code and version is > the version being installed --> <UpgradeVersion Minimum="$(var.CurrentVersion)" IncludeMinimum="no" OnlyDetect="yes" Language="1033" Property="NEWERPRODUCTFOUND" /> <!-- Populate UPGRADEFOUND if there is an installed package with the same upgrade code and the version is between the earliest version defined and the version being installed --> <UpgradeVersion Minimum="$(var.FirstVersion)" IncludeMinimum="yes" Maximum="$(var.CurrentVersion)" IncludeMaximum="no" Language="1033" Property="PREVIOUSVERSIONSINSTALLED" /> </Upgrade> 

I defined the following in MyProduct.wxs

 <?define CurrentVersion="5.0.0.18"?> <?define FirstVersion="1.0.0.0"?> <?define UpgradeCode="c1b1bfa0-9937-49eb-812c-5bac06eff858"?> 

and finally i added this to my <InstallExecuteSequence>

 <RemoveExistingProducts Before="InstallInitialize" /> 

But it still does not delete the old version when I upgrade my version to 5.0.0.19.

Maybe I am looking at it wrong, but in my window “Add or Remove Programs” I see that my installation is listed as 5.0.0.18 and I see the second entry as 5.0.0.19

Should I change the update code every time I change my version? I thought I read that this should never change.

Any ideas?

Thanks.

+6
source share
2 answers

I understood the answer after a lot of searching! Windows Installer does not account for 4 version numbers that I use ie 5.0.0.18.

He only looks at the first 3 sets of numbers that make the version number. As soon as I changed my version from 5.0.18.0 to 5.0.19.0, she immediately worked with the code sent in the question, and deleted the previous version and installed a new one on it.

Please note that I really deleted the above code and ended up using MajorUpgrade, as that is all I need:

 <MajorUpgrade AllowDowngrades="no" AllowSameVersionUpgrades="no" IgnoreRemoveFailure="no" DowngradeErrorMessage="loc.NewerVersionInstalled" Schedule="afterInstallInitialize"/> 

Hope this helps someone else!

+11
source

Here is the documentation for the AllowSameVersionUpgrades attribute of a AllowSameVersionUpgrades element. It contains relevant information. The emphasis is mine.

If set to no (default), installing a product with the same version and update code (but a different product code) is allowed and processed by MSI as two products. When set to yes, WiX installs msidbUpgradeAttributesVersionMaxInclusive , which tells MSI to process the product with the same version as the main update.

This is useful when two versions of a product differ only in the fourth version. MSI specifically ignores this field when comparing the product version, so two products that differ only in the fourth version field are the same product, and for this attribute you must set yes to detect.

Note that since MSI ignores the version field of the fourth product, setting this attribute to yes also allows downgrades when the first three fields of the product version are identical. For example, construction work version 1.0.0.1 will be “updated” 1.0.0.2998, because they are considered as the same version (1.0.0). This can lead to serious errors, so the safest choice is to change the first three fields of the version and omit this attribute to get the default value.

This attribute cannot be “yes” when AllowDowngrades also “yes” - AllowDowngrades already allows you to use two products with the same version number to update each other.

Setting this attribute to yes is probably not , however, because, according to the third paragraph, version 5.0.0.18 will be considered an update to version 5.0.0.19. Set this attribute to no and use the version field of the third product to allow updates.

+3
source

Source: https://habr.com/ru/post/976662/


All Articles