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

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.

Related

Wix MajorUpgrade not working, after changing UpgradeCode GUID & Version

We are using the following code in our Wix Packages.wxs file, as per the documentation we are changing the UpgradeCode GUID & Version number from. 1.0.1.0 to 1.0.2.0 but when we build and try to install the msi package it says older version is still installed and we need to uninstall it to continue.
<Product Id="8B3DFDFF-D894-4A31-AA92-824729385F15" Name="WixCodeBase" Language="1033" Version="1.0.2.0" Manufacturer="Company Name" UpgradeCode="C78D9362-A156-44A2-94D0-AFA19389FFE8">
<Package Id="*" Keywords="Installer" Manufacturer="Company Name" Description="Wix Installer" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade Schedule ="afterInstallValidate" AllowDowngrades="no" DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<Media Id='1' Cabinet='WixPackage.cab' EmbedCab='yes' />
Installer Error
For major upgrades, you change the Product element's Id attribute not the UpgradeCode attribute. In fact, UpgradeCode attribute must remain constant across versions to use the MajorUpgrade element. MSDN has all the details.
I maintain an open source project called IsWiX that provides templates and designers to accelerate the WiX / MSI learning and development process. One of the many things these templates do out of the box is provide proper Major Upgrade support. Consider this code generated by the template:
Code Source
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<!--
MSIProductVersion is defined in DesktopApplication.wixproj as 0.0.1 for local desktop builds.
You should pass in the MSBuild Property 'MSIProductVersion' to override it during an automated build.
See http://msdn.microsoft.com/en-us/library/windows/desktop/aa370859%28v=vs.85%29.aspx for information on allowable values.
The Product#Id attribute (ProductCode Property) will be a random GUID for each build. This is to support "Major Upgrades" where each install
is a seamless uninstall/reinstall.
-->
<Product Id="*" Name="DesktopApplication" Language="1033" Version="$(var.MSIProductVersion)" Manufacturer="DesktopApplication" UpgradeCode="7220a19b-ed49-4cd1-8002-6af7926441b4">
<Package InstallerVersion="301" Compressed="yes" InstallScope="perMachine" />
<MediaTemplate EmbedCab="yes" />
<!-- Major Upgrade Rule to disallow downgrades -->
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<!--Common Launch Condition-->
<!-- Examples at http://wixtoolset.org/documentation/manual/v3/customactions/wixnetfxextension.html -->
<PropertyRef Id="NETFRAMEWORK40FULL"/>
<Condition Message="[ProductName] requires .NET Framework 4.0.">Installed OR NETFRAMEWORK40FULL</Condition>
<!-- Include User Interface Experience -->
<Icon Id="Icon.ico" SourceFile="Resources\Icon.ico"/>
<Property Id="ARPPRODUCTICON" Value="Icon.ico"></Property>
<UIRef Id="UI"/>
<!-- Include Features and Directories Fragment -->
<DirectoryRef Id="INSTALLLOCATION"/>
</Product>
</Wix>
In addition to be documented in the comments, it's also discussed in the tutorials.
In a nutshell, you need to keep UpgradeCode the same and randomize ProductCode.

Properly install a higher version MSI in 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.

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 - Upgrade will old installation and install new one

I want that my installer, if detect a old one, previously uninstall it and then launch the installation of the new one.
I've the following Wix XML:
<Product Id="16bf910b-3b0f-4240-914a-81526bce35f4"
Name="MyProduct"
Language="1033"
Version="1.0.0.0"
Manufacturer="MyCompany"
UpgradeCode="6ba28d97-41de-4371-a236-b757b7840f7b">
<Package InstallerVersion="200" Compressed="yes" />
<Upgrade Id="6ba28d97-41de-4371-a236-b757b7840f7b">
<UpgradeVersion Minimum="0.0.0.0"
IncludeMinimum="yes"
OnlyDetect="no"
Maximum="1.0.0.0"
IncludeMaximum="yes"
Property="PREVIOUSFOUND" />
</Upgrade>
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallValidate"/>
</InstallExecuteSequence>
When generating the MSI file, install it (version 1.0.0.0), it's ok.
Now I changed the Product/#Version to 1.0.1.0 and click on MSI again, at this point I get a messge : "A previous installation of this product exists, please remove it first ...".
How can I modify this behavior?
Thanks
Product#Id maps to the Windows Installer ProductCode property. This Id must change from build to build in order to be a Major Upgrade. You can set it to "*" to let the compiler handle this for you.