Wix - Upgrade will old installation and install new one - wix

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.

Related

ICE61: This product should remove only older versions of itself. The Maximum version is not less than the current product

I am getting the following warning in Visual Studio:
ICE61: This product should remove only older versions of itself. The Maximum version is not less than the current product.
I have found this answer on StackOverflow, but I can't apply what it says, my code only has this:
<Product Id="*" Name="Product Name" Language="1033" Version="1.0.0.2" Manufacturer="Ace Software" UpgradeCode="d2562e98-94df-8938-ba21-0967b39ed389">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MediaTemplate EmbedCab="yes" />
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallFinalize" />
</InstallExecuteSequence>
<Property Id="PREVIOUSVERSIONSINSTALLED" Secure='yes' />
<Upgrade Id="d2562e98-94df-8938-ba21-0967b39ed389">
<UpgradeVersion Minimum="0.0.0.0"
IncludeMinimum="yes"
Maximum="100.100.100.100"
Property="PREVIOUSVERSIONSINSTALLED" />
</Upgrade>
<!-- other code ommited -->
</Product>
As you can see, I don't have a MajorUpgrade element where I can set the AllowSameVersionUpgrades to no.
How do I get rid of the warning? I don't really want to supress it, but actually fix the issue.
MSI can recognize only 3 first digits of version, 4th digit is omitted, version 1.0.0.2 and 1.0.0.3 are recognized as the same. Also it's recommended to use MajorUpgrade element to allow upgrade. Have a look at the major upgrade documentation

Wix MSI installer is not removing previous version from "Add/Remove Applications" when updating the application

I have created a new installer with a new version and Product ID with no errors but when it is installed, the current version remains installed as well as the updated version. I have been using this for a while to install and update my application on different machines but only recently has it started to not delete the old version completely. I have updated the .wxs file as follows:
1. Changed <Product Id="{F9030CA1-39AD-46BD-B2E2-3DBE02A8845B}".
2. Updated the new version number.
I have not updated the Upgrade Code.
I have created multiple versions of the installer to see if the problem persist and it seems as it does. I have also updated the Wix extension to visual studio (Votive2019) but no luck.
Not sure if there is a fault with my code or if this is a bug. I am not even sure what the cause of this problem is.
Below is a snippet of my code from the package section:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="{F9030CA1-39AD-46BD-B2E2-3DBE02A8845B}" Codepage="1252" Language="1033" Manufacturer="Mi-Plan" Name="FD to Excel" UpgradeCode="{17469B04-7B24-455E-BCB8-CD7AEA97CDCD}" Version="10.0.560">
<Package Compressed="yes" Description="10.0.560.0" InstallerVersion="200" Languages="1033" Manufacturer="Jwayela Software" Platform="x86" />
Below is a snippet of my code from the upgrade section:
<Upgrade Id="{A39F99F9-069F-4356-AA6A-5BBBC6DADB29}">
<UpgradeVersion Maximum="10.0.560" Property="PREVIOUSVERSIONSINSTALLED" />
<UpgradeVersion Minimum="10.0.560" Property="NEWERPRODUCTFOUND" OnlyDetect="yes" IncludeMinimum="yes" />
</Upgrade>
I am using Visual Studio 2019.
Click here to get full file.
Type Mismatch Error: It looks like there is a mismatch between the Upgrade element's "Id" value and the Upgrade Code you have specified in the Product element? That would explain why the major upgrade doesn't work, but not why it has worked so far?
Major Upgrade Element: Would recommend you use the simplified major upgrade element if you don't need fine grained control in the Upgrade table for something special. I just wrote an answer for this a few hours ago: Unable to remove previous versions of MSI. Multiple entry's show up in control panel. Magixal MajorUpgrade element - this single, simple line does all the work for you:
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
Define: Another thing is that Defines can be used to set values that are to be used in different places in the source and need to match exactly all the time:
<?define MyProductVersion = "31.00.0000" ?>
<?define MyProductCode = "PUT-GUID-HERE" ?>
<?define MyUpgradeCode = "PUT-GUID-HERE" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="$(var.MyProductCode)" Codepage="1252" Language="1033" Manufacturer="Corp"
Name="Bla" UpgradeCode="$(var.MyUpgradeCode)" Version="$(var.MyProductVersion)">
<...>
<!-- Major upgrade -->
<Upgrade Id="$(var.MyUpgradeCode)">
<!-- Downgrade Protection -->
<UpgradeVersion Minimum="$(var.MyProductVersion)" OnlyDetect="yes"
IncludeMinimum="yes" Property="DOWNGRADE_DETECTED" />
<!-- Major Upgrade Configuration -->
<UpgradeVersion IncludeMinimum="no" Maximum="$(var.MyProductVersion)"
IncludeMaximum="no" MigrateFeatures="yes" Property="UPGRADE_DETECTED" />
</Upgrade>
</Wix>

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 - How to selectively uninstall the <Bundle>

I want to retain the previous versions of my Bootstrapper App, how to achieve this?
I know that we can use the Upgrade tag in MSI where we can identify the different versions and perform uninstall operations base on those.
Now, I have a Bundle Application that has one or more MSI which use some UpgradeCode. Each time I create a new build I just version up the MSI and this Bundle Application. When I proceed with installing of later version of Bundle App, it uninstall the previous Bundle version, which is not what I want. I want to retain the previous versions of my Bundle Application.
Is there anything like UpgradeVersion in Bundle as well, where we would be able to identify the diferent versions and do selectively uninstall.
My Bundle file code snippet :
<Bundle Name="myApp"
Version="1.0.0.0"
Manufacturer="Myself"
UpgradeCode="SOME-GUID">
<BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost" >
...
</BootstrapperApplicationRef>
<Chain>
<PackageGroupRef Id= 'WindowsInstaller45'/>
<PackageGroupRef Id ='NetFx45Offline'/>
<PackageGroupRef Id ='MY_MSI'/>
</Chain>
</Bundle>
<Fragment Id ='PkgFragments'>
<PackageGroup Id ="MY_MSI">
<MsiPackage SourceFile= "$(var.Installer.TargetPath)"
Id="MYAPP"
Cache ="yes"
Visible ="no"
DisplayInternalUI ="no"
Permanent="no">
<MsiProperty Name='INSTALLLOCATION' Value='[InstallFolder]' />
<MsiProperty Name='SELECT_UNINST' Value='[UninstallPrevVersion]' />
</MsiPackage>
</PackageGroup>
</Fragment>
My Product WIX file code snippet
<Product Id="*"
Name="$(var.ProductName)"
Version="$(var.ProductVersion)"
Manufacturer="$(var.ManufacturerName)"
UpgradeCode="$(var.UpgradeCode)">
<Property Id="SELECT_UNINST" Secure="yes">1</Property>
<Upgrade Id="SOME-GUID2">
<UpgradeVersion Minimum="0.0.0.0" Maximum="$(var.ProductVersion)" IncludeMinimum="yes" IncludeMaximum="yes" Property="UNINSTALL_PREV_VERSION" />
</Upgrade>
<CustomAction Id="UninstPrev" Property="UNINSTALL_PREV_VERSION" Value="0" />
<InstallExecuteSequence>
<Custom Action="UninstPrev" Before="InstallInitialize"><![CDATA[SELECT_UNINST <> 1]]></Custom>
<RemoveExistingProducts Overridable="no" After="UninstPrev"></RemoveExistingProducts>
</InstallExecuteSequence>
</Product>
I'll put this as an answer too.
If you don't want to remove your previous versions don't treat the new version as an upgrade to the old one. This means change the upgrade GUID and change the product GUID. If you need to remove a specific version, add the bundle as a <RelatedBundle> in your Bundle definition and properly handle OnPlanRelatedBundle in your Bootstrapper Application.
<RelatedBundle Action="Detect" Id="$(var.ProductVersion622UpgradeGUID)"/>
Additionally, any msi packages you install also would need to employ the same behaviour of new upgrade GUIDs if you don't want removal between "upgrades". Keep a list of which GUIDs are with which released versions. If you want to remove specific versions in a release of your msi you need to add
<Upgrade Id="$(var.Version6InstallerUpgradeGUID)" >
<UpgradeVersion
IncludeMaximum ="no"
IncludeMinimum="yes"
Maximum="6.0.0.1"
Minimum="6.0.0.0"
MigrateFeatures="no"
Property="V6FOUND"
OnlyDetect="no" />
</Upgrade>
I would consider this requirement very odd and would suggest you really think upon whether or not you really want to support this kind of behaviour.
Also to note, the entry in the ARP for the bootstrapper existing doesn't necessarily mean the products it installed are still on the system. You can test this by always setting pRequestedState = RequestState.Present; in OnPlanRelatedBundle and setting your msi packages to visible="yes". You will have the old bundle listed in the ARP but the packages it installs were probably upgraded by the newer version so it's just an entry that doesn't mean anything.

How to get WiX major upgrade working?

I am struggling to enable the major upgrade functionality in WiX.
I want every new version of the installer to be a major upgrade (full uninstall, then new install) as we don't want different upgrade and clean install versions.
I started off trying to do it using the tag stuff, but I kept getting "Another version is installed." error message when I run the installer.
So I implemented the new tag that was added in V3.5 to make upgrades easier. I was still getting the error message.
I then read somewhere that you need to change the Id GUID for each new version. So I set Id="*" to get WiX to generate them.
Now when I install the newer version it doesn't uninstall the older version, and you end up with two installations to the same folder. I worked this out because running either MSI (new or old) would bring up the repair/remove screen.
Also the program was not overwritten with the new version.
Here is the start of my WiX script:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
Name="Foo"
Language="1033"
Codepage="1252"
Version="!(bind.FileVersion.Foo.exe)"
Manufacturer="Foo Bar Ltd."
UpgradeCode="dac2fab2-7d76-4e47-b25f-0748380dab81">
<Package
Description="Foo"
Comments="This installer database contains the logic and data required to install Foo."
InstallerVersion="300"
Languages="1033"
SummaryCodepage="1252"
Platform="x86"
Compressed="yes" />
<!-- Remove older versions -->
<!-- Important note: MSI ignores the last version digit 1.0.0.? when comparing versions, so always change at least the 3rd digit for new external releases-->
<MajorUpgrade DowngradeErrorMessage="The version currently installed is newer than the version you are attempting to install."/>
Here's a snippet of what I use for all my packages, refined over many internal and public releases
<Product Id="*"
UpgradeCode="$(var.Property_UpgradeCode)"
Name="!(loc.ApplicationName)"
Language="!(loc.Property_ProductLanguage)"
Version="$(var.version)"
Manufacturer="!(loc.ManufacturerName)" >
<Package Description="!(loc.Package_Description) $(var.version)"
Comments="!(loc.Package_Comments)"
Manufacturer="!(loc.ManufacturerName)"
InstallerVersion="301"
Compressed="yes"
InstallPrivileges="elevated"
InstallScope="perMachine"
Platform="$(var.ProcessorArchitecture)" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<Upgrade Id="$(var.Property_UpgradeCode)">
<UpgradeVersion OnlyDetect="yes"
Minimum="$(var.version)"
Property="NEWERVERSIONDETECTED"
IncludeMinimum="no" />
<UpgradeVersion OnlyDetect="no"
Maximum="$(var.version)"
Property="OLDERVERSIONBEINGUPGRADED"
IncludeMaximum="no" />
<!-- Detect for changes in 4th field only -->
<UpgradeVersion Property="ANOTHERBUILDINSTALLED"
Maximum="$(var.version)" Minimum="$(var.version)"
IncludeMinimum="yes" IncludeMaximum="yes" OnlyDetect="yes" />
</Upgrade>
<CustomAction Id="CA_BlockOlderVersionInstall" Error="!(loc.LaunchCondition_LaterVersion)" />
<CustomAction Id="CA_BlockAnotherBuildInstall" Error="!(loc.LaunchCondition_AnotherBuild)" />
<InstallExecuteSequence>
<Custom Action="CA_BlockOlderVersionInstall" After="FindRelatedProducts">
<![CDATA[NEWERVERSIONDETECTED]]>
</Custom>
<!-- Prevent installation on 4th version field change only -->
<Custom Action="CA_BlockAnotherBuildInstall" After="FindRelatedProducts">
<![CDATA[ANOTHERBUILDINSTALLED]]>
</Custom>
<LaunchConditions After="AppSearch" />
<!-- Schedule RemoveExistingProducts early -->
<RemoveExistingProducts After="InstallInitialize" />
</InstallExecuteSequence>
<InstallUISequence>
<Custom Action="CA_BlockOlderVersionInstall" After="FindRelatedProducts">
<![CDATA[NEWERVERSIONDETECTED]]>
</Custom>
<!-- Prevent installation on 4th version field change only -->
<Custom Action="CA_BlockAnotherBuildInstall" After="FindRelatedProducts">
<![CDATA[ANOTHERBUILDINSTALLED]]>
</Custom>
<LaunchConditions After="AppSearch" />
</InstallUISequence>
<!-- .... -->
</Product>
If it's of any use to those who discover this thread, I've also encountered a similar problem which I've just figured out.
In my case (and still having been in early stages of developing my installer), the critical difference was that, between versions, I had switched from a per-user install to a per-machine install. More specifically, I'd added the following line to my Product.wxs:
<Property Id='ALLUSERS' Value='1'/>
I'm still getting my head around many of the idiosyncrasies of Windows Installers, but I'd assume that by switching the type of installation in this way would be comparable with shifting to a mutually exclusive stream of versioning in many ways (even enabling two identical versions to be installed in parallel!).
It's a shame that the Windows Control Panel doesn't clearly distinguish between installations which are per-user and all-users.
I know this post is old and answered, but, in case anyone runs across this, I had issues with my upgrade installer. The upgrade sections were all fine. The installer would run, but, the previous version was never removed, therefore, the new version was not installed. The issue was this
<Feature Id="ProductBinaries" Title="ProductBinariesInstaller" Level="0">
The Level="0" above, should have been Level="1" as it is below:
<Feature Id="ProductBinaries" Title="ProductBinariesInstaller" Level="1">
Scott