Properly install a higher version MSI in WIX - wix

I want to remove/uninstall pre-installed lower version MSI before/with installation of a higher version of MSI. My product codes are always unique and upgrade codes are always the same.
(I don't want to allow downgrading installation.)
But when I install a higher product version MSI, it gets installed but the add/remove program entries for both new installed and previously installed MSIs still exist. How to overcome this issue ? Following is my code
<Product Id="*" Name="MyApp" Language="1033" Version="1.11.1111" UpgradeCode="00000000-8030-4B76-8F3A-8B8BB1000000">
<Package InstallerVersion="200" Compressed="yes" Platform="x86" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." AllowDowngrades="no" Schedule="afterInstallInitialize"/>
<Upgrade Id="{00000000-8030-4B76-8F3A-8B8BB1000000}">
<UpgradeVersion OnlyDetect="no" Maximum="99.0.0.0" Property="PREVIOUSVERSIONSINSTALLED" IncludeMaximum="no"/>
<UpgradeVersion OnlyDetect="yes" Minimum="1.0.0.0" Property="NEWERPRODUCTFOUND" IncludeMinimum="no"/>
</Upgrade>

As you can see from this:
http://www.joyofsetup.com/2010/01/16/major-upgrades-now-easier-than-ever/
The MajorUpgrade element replaces the Upgrade elements. You've got both upgrade types specified so that may be causing some issues.
If the version has incremented in the first three fields, the UpgradeCode is the same and the ProductCode is new, then the most likely cause of a failure (and getting two entries installed) is that the prior one was perUser (or perMachine) and your upgrade is the opposite. Major upgrades must be in the same context.

Related

WiX upgrade doesn't work after changing from per machine to per user installation. How can I uninstall the old version?

WiX Toolset Version: 3.11.2.4516
To switch from a per machine to a per user installation, I changed my WiX configuration from this:
<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="1.0.0.1"
Manufacturer="$(var.CompanyName)" UpgradeCode="eec853e6-9345-4be0-908f-958f212c6f30">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated" />
<MajorUpgrade Schedule="afterInstallInitialize"
DowngradeErrorMessage="A newer version of $(var.ProductName) is already installed" />
To this (remove Package/#InstallScope and Package/#InstallPrivileges):
<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="2.0.0.0"
Manufacturer="$(var.CompanyName)" UpgradeCode="eec853e6-9345-4be0-908f-958f212c6f30">
<Package InstallerVersion="200" Compressed="yes" />
<MajorUpgrade Schedule="afterInstallInitialize"
DowngradeErrorMessage="A newer version of $(var.ProductName) is already installed" />
Now the product is installed per user instead of per machine. But the <MajorUpgrade> doesn't work anymore. I also tried to change the Product/#UpgradeCode to a new GUID and add the following to my WiX config (below the <MajorUpgrade> element):
<Upgrade Id="eec853e6-9345-4be0-908f-958f212c6f30">
<UpgradeVersion OnlyDetect="no" Property="OLD_SERVICE_INSTALLER_FOUND" Minimum="0.0.0.0" />
</Upgrade>
But that doesn't work either.
How can I uninstall the old version of my software, if I switched from per machine to per user installation?
Your stuck. This is a windows installer limitation.
https://learn.microsoft.com/en-us/windows/win32/msi/major-upgrades
Note
If an application is installed in the per-user installation context,
any major upgrade to the application must also be performed using the
per-user context. If an application is installed in the per-machine
installation context, any major upgrade to the application must also
be performed using the per-machine context. The Windows Installer will
not install major upgrades across installation context.

WIX: upgrade without removing old version

I have installed version 2.4.0. And I have an major update:
<?define Version="2.4.1.0"?>
<Product Id="*" Name="SuperProduct" Language="1033" Version="$(var.Version)" Manufacturer="MyCompany" UpgradeCode="$(var.UpgradeCode)">
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion Minimum="1.0.0.0" Maximum="3.0.0.0" Property="PREVIOUSVERSIONSINSTALLED" IncludeMinimum="yes" IncludeMaximum="no" IgnoreRemoveFailure="yes" />
</Upgrade>
<MajorUpgrade AllowDowngrades="no" DowngradeErrorMessage="Cannot downgrade!" IgnoreRemoveFailure="yes" AllowSameVersionUpgrades="no" />
The major update should replace few dll files in my product (it contains only theese files). But the installer removes old version and installs new one. All old files except new files are removed. How can I install upgrade without removing old files (suppress RemoveExistingProducts). This is not an option to remove MajorUpgrade tag and receive 2 programs in Program Files (SuperProduct 2.4.0 and SuperProduct 2.4.1)
Do you have any ideas?
Make a patch instead of an upgrade. This is exactly what patches are for, replacing a few key files and leaving the rest of the install as-is. I haven't made a patch install yet but the steps should be in the wix tutorial or in Nick Ramirez's Wix 3.6 book. A minor upgrade may also work, I'm not 100% sure about the differences between the upgrade types as I always just implement a major upgrade

upgrade version using WIX

I've made an installer using the WIX toolset (3.10). I'd like to enable upgrades but I can't make it work. Every time I run the msi it installs another version.
I can't figure out what's wrong. can anyone advise?
<Product Id="*"
Name="$(var.PRODUCTNAME)"
Language="1033"
Version="$(var.PRODUCTVERSION)"
Manufacturer="Manufacturer"
UpgradeCode="UPGRADE_CODE"
>
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine" />
<MajorUpgrade Schedule="afterInstallInitialize"
AllowDowngrades="no"
AllowSameVersionUpgrades="no"
DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
AllowSameVersionUpgrades="yes" will probably fix this. When you test upgrades you need to either always update the version (one of the first 3 parts) between installers or just allow the same version upgrades.
from the wix website
When set to no (the default), installing a product with the same version and upgrade code (but different product code) is allowed and treated by MSI as two products. When set to yes, WiX sets the msidbUpgradeAttributesVersionMaxInclusive attribute, which tells MSI to treat a product with the same version as a major upgrade.
So your install thinks these two installs are separate things even though they share the same upgrade code which is why you get 2 copies in your add remove programs list.
I use a GUID for the UpgradeCode (I suppose that's what UPGRADE_CODE means).
You can also set the REINSTALLMODE property to change your reinstallation behavior.
It could look like this:
<SetProperty Id="REINSTALLMODE" Value="amus" After="FindRelatedProducts">Installed AND REMOVE<>"ALL"</SetProperty>
Just be aware that a will reinstall your product regardless of the installed version. But you can look up which characters you need for your installer.
For Value="amus" you can refer to the Microsoft documentation here
In addition to your MajorUpgrade property it is crucial that your UpgradeCode does not change for future versions. Might that be the problem?

WiX creating duplicate records in ARP when I change the version number

My WiX installer does not uninstall previous version record in ARP when I change the version number. It installs the updated files, but I end up with duplicate records in ARP. Does this have something to do with minor versus major upgrades? The beginning of my WiX installer file is as follows:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="Blah" Language="1033" Version="1.0.0.6" Manufacturer="Blah Inc." UpgradeCode="c6044fe4-e07a-4dd0-9540-cc77b4430466">
<Package Id ="*" Keywords="Installer" Description="Blah Installer" Manufacturer="Blah Inc." InstallerVersion="200" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated" />
<Property Id="OLDVERSION" Secure="yes" />
<Upgrade Id="7BDF86F7-C6A8-4112-9DA6-FDFB6864AE66">
<UpgradeVersion OnlyDetect="no" Minimum="1.0.0.0" Maximum="99.0.0.0" Property="OLDVERSION" IncludeMinimum="yes" IncludeMaximum="no" />
</Upgrade>
<InstallExecuteSequence>
<RemoveExistingProducts Overridable="no" After="InstallInitialize" />
</InstallExecuteSequence>
Couple of things to check:
Is the Upgrade ID same for both MSI's? The MSI wont know that there is a related product installed unless the upgrade GUID's are same.
Looks like you have updated only the last digit of the version number? if your version 1 uses Version value 1.0.1.0, then version 2 should have a Version value of 1.0.2.0 or higher (1.0.1.1 will not work here).
From Wix3.5, there is a new element called MAJORUPGRADE MajorUpgrade which consolidates the lines which you have written and makes things easier. Can you make use of that and see if it works? Here is a link to Bob Arnsons blog introducing "MajorUpgrade" MajorUpgrade
Check this link for more details: How to implement major upgrade
Your Upgrade Code must generally be stable across versions to identify the products in question as related. They seem to differ in your code.
Furthermore you must implement a major upgrade to ensure that the old product version is uninstalled before the new one is installed. Otherwise you will get multiple installations showing up in ARP.
For good measure always uppercase your GUIDs, though I believe WIX will do this for you on compile. And make sure you uninstall all versions of your application before you try anything else.

Unable to update wise installer package with wix installer

I have a msi setup file which was created with wise for windows installer. Now I want to create a new version of this installer with Wix toolset. The problem is, that the installer detects the previous installed (wise created) version, but isn't able to upgrade it. I get the following error message:
"Another version of this product is already installed. Installation of this version cannot continue. To configure or remove the existing version of this product, use Add/Remove Programs on the Control Panel"
I set the same upgrade code in both installers and chacnged the product code and the package code in the wix project. I set the upgrade informations as follows:
<!-- Upgrade information -->
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion Property="NEWPRODUCTFOUND"
IncludeMinimum="no"
Minimum="$(var.ProductVersion)"
OnlyDetect="yes"/>
<UpgradeVersion Property="OLDPRODUCTFOUND"
IncludeMinimum="yes"
Minimum="0.5.0"
IncludeMaximum="no"
Maximum="$(var.ProductVersion)"/>
<UpgradeVersion Property="NEWERVERSIONINSTALLED"
IncludeMinimum="yes"
Minimum="$(var.ProductVersion)"
OnlyDetect="yes" />
</Upgrade>
I also tried to ensure that the product will be installed for all users by setting the InstallScope to "perMachine"
<Package InstallerVersion="200"
InstallScope="perMachine"
Compressed="yes" />
I have other installer projects where all versions were created with wix and for them the upgrade works fine.
Make sure you increase the Product Version. Only newer product version can automatically upgrade the original package.
Also, please note that Windows Installer ignores the fourth version field (in case you are using it).