How to add the message <Major upgrade DowngradeErrorMessage="A newer version of product name is already installed"/> in bootstrapper project - wix

How to add the message in bootstrapper project.
If I execute the bootstrapper package exe file Second time means it is showing the uninstall option not "A newer version of product name is already installed". Pls help

<!-- AllowSameVersionUpgrades -> Always upgrade, never allow two versions to be installed next to each other -->
<!-- AllowSameVersionUpgrades causes ICE61 which must be ignored -->
<MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A newer version of [ProductName] is already installed. Setup will now exit." AllowSameVersionUpgrades="yes"/>

Related

With Wix Toolset is there a way with MajorUpgrade to set a minimum version

We have been using the MajorUpgrade element in wix 3.11.1.2318, and our installer is not upgrading properly. It is not removing files and is leaving an extra entry in add/remove programs. During our build we switch Version="0.0.0.0" with the current version.
Below is a reduced sample to show our usage:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" >
<Product Id="*" Name="My Product" Language="1033" Version="0.0.0.0" Manufacturer="MyCompany"
UpgradeCode="{B55B9CB0-BA28-4BB3-834B-6075AD5D45E4}">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<UIRef Id="WixUI_ErrorProgressText" />
<!-- Specify UI -->
<Property Id="WIXUI_INSTALLDIR" Value="INSTALL_FOLDER" />
<Property Id="RestoreFiles" Value="INSTALL_FOLDER" />
<MajorUpgrade AllowDowngrades="no" AllowSameVersionUpgrades="yes" DowngradeErrorMessage="!(loc.NewerVersionInstalled)" />
</Wix>
I looked at the Upgrade table in our msi, one entry had the MinVersion set to the version we had built and with no max version.
Another entry had the MaxVersion set to the version we had just built, and with no min version.
I thought that with the MinVersion set to our current version we would not be able to remove the files, so I looked
at the Upgrade element and replaced the MajorUpgrade element.
<!--
<MajorUpgrade AllowDowngrades="no" AllowSameVersionUpgrades="yes" DowngradeErrorMessage="!(loc.NewerVersionInstalled)" />
-->
<Upgrade Id="{B55B9CB0-BA28-4BB3-834B-6075AD5D45E4}">
<UpgradeVersion Minimum="1.0.0"
IncludeMinimum="yes"
OnlyDetect="no"
Maximum="0.0.0.0"
IncludeMaximum="no"
Property="OLDVERSIONFOUND" />
</Upgrade>
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallInitialize" />
</InstallExecuteSequence>
This did remove the older files, but left the second add/remove programs entry.
Is there a way with MajorUpgrade to set a minimum version?
Should I stay with Upgrade if there is no method to set minimum version?
What might be causing the second entry?
Logging: Please make sure to create a proper verbose log file for better clues to what is going on.
Major Upgrades: Some previous answers:
Here is a list of common causes of failed major upgrades (please skim the list first)
The use of both legacy and modern constructs to implement major upgrades.
Annotated WiX source showing old style major upgrades constructs in use
The upgrade settings you describe sound normal for WiX. I assume your build process successfully replaces the placeholder 0.0.0.0 (you search for that and replace it I presume). You could also use WiX variables and pass the value in, but that is another story.
Dangling Version?: Are you sure you don't have a dangling version in Add / Remove that isn't removed because it was a test version or something like that? Try generating a list of installed packages. Previous link is for a script which creates a small HTML report, you can try this simpler script to create output in *.csv format (which you can import to Excel and sort by name column to find duplicates easily). Try to install on a clean virtual to make sure. Just need to verify that this is not the case - one of those things that can be left unverified and be the cause.
Upgrade Table: Below is a sample upgrade table. Notice that the first entry is for the real major upgrade. It will detect all lower versions than the max version specified. You don't need to upgrade if your version is already installed. Hence we don't need max to be higher than the current version we install. In fact if the version you try to install you are supposed to go into "maintenance mode" - which shows a list of features you have installed and whatever features you have not installed.
The second row is to prevent overwriting a higher, existing installed version with a lower version than the setup you are running.

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.

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?

ICE61: This product should remove only older versions of itself

I was following the second answer here in order to avoid "already installed" message for my newer installation packages. So this is the items I've changed. Everything is ok and I'm getting newer versions installed properly.
<Product Id="*" Name="Product Name" Language="1033" Version="1.9.0.0" Manufacturer="ABCD" UpgradeCode="e820aa3a-0288-45d8-a357-41bc065bbed0">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
However, compiler gives me the following warning message:
ICE61: This product should remove only older versions of itself. The
Maximum version is not less than the current product. (1.9.0.0
1.9.0.0)
I can't just ignore this message. So the question is how to fix this warning?
The warning comes from AllowSameVersionUpgrades=Yes. As you write in comment "I never wanted to upgrade between identical versions and always increment second(or even first)", then you dont need AllowSameVersionUpgrade, so just remove it.
WiX allows you to do same-version installs, but Microsoft doesn't recommend it, hence the warning message.
You can either carry on as is (and live with the compiler whinge), or change your MajorUpgrade section to this:
<MajorUpgrade
AllowSameVersionUpgrades="no"
DowngradeErrorMessage="A newer version of [ProductName] is already installed. If you are sure you want to downgrade, remove the existing installation via the Control Panel" />
If you want to suppress the warning, you need to add a -sw1076 flag to light.exe. 1076 is the Wix error code, ICE61 is the Microsoft error code.
You can suppress warnings like this:
&"$($env:WIX)\bin\light.exe" -sice:ICE61 "installer\myproduct.wixobj"

Dealing with Changed Upgrade Code in WiX, where old installer allowed both per-user and per-machine

I have a product that used to ship with a .vdproj installer. In the most recent version, I shipped a beta with a completely redone installer using WiX (as part of the move to Visual Studio 2012, which no longer supports .vdproj). Unfortunately, at the time I didn't know that the upgrade code was supposed to be consistent across copies, and already shipped one beta installer with a different upgrade code.
I would like my installer to automatically remove previous versions built with the .vdproj installer, as well as the version that was shipped as a beta copy. This is where I've gotten so far:
<Product Id="{A4CBA9F9-D86B-400C-BD23-996B4367931A}" Name="Foo Viewer" Language="1033" Version="6.0.1.0" Manufacturer="Foo Corporation" UpgradeCode="43e024b8-b3ea-40a3-a854-2af83f207f0f">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MediaTemplate EmbedCab="yes" />
<Feature Id="FOOVIEWERFeature" Title="Foo Viewer" Level="1" Description="The Foo Viewer GUI and CLI binaries." AllowAdvertise="no" Absent="disallow" Display="expand">
<!-- Stuff -->
</Feature>
<PropertyRef Id="NETFRAMEWORK40CLIENT" />
<Condition Message="Foo Viewer requires the .NET Framework 4.0 Client Profile or higher to run.">Installed OR NETFRAMEWORK40CLIENT</Condition>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<UIRef Id="FooViewerInstallerUI" />
<UIRef Id="WixUI_ErrorProgressText" />
<Icon Id="FooViewerIcon" SourceFile="../FooViewer.ico" />
<Property Id="ARPPRODUCTICON" Value="FooViewerIcon" />
<!-- I got this upgrade code by opening one of the old .vdproj MSIs in Orca -->
<Upgrade Id="{80539F30-8176-4DCC-A102-ED32A34A91CB}">
<UpgradeVersion OnlyDetect="no"
Minimum="0.0.0.0"
IncludeMinimum="yes"
MigrateFeatures="no"
IgnoreRemoveFailure="no"
Property="UPGRADE_VDPROJ_FOOVIEWER"
/>
</Upgrade>
<Upgrade Id="{43e024b8-b3ea-40a3-a854-2af83f207f0f}">
<!-- Foo Viewer 6.0.0.0 (Beta) shipped with a version 5.3.0.0 in the installer. -->
<UpgradeVersion OnlyDetect="no"
Minimum="5.3.0.0"
Maximum="5.3.0.0"
IncludeMinimum="yes"
IncludeMaximum="yes"
MigrateFeatures="yes"
IgnoreRemoveFailure="no"
Property="UPGRADE_WIX_FOOVIEWER"
/>
<!-- Detect newer versions -->
<UpgradeVersion OnlyDetect="yes"
Minimum="6.0.1.0"
IncludeMinimum="no"
Property="NEW_VERSION_FOUND"/>
</Upgrade>
<Condition Message="A newer version of Foo Corporation Foo Viewer is already installed.">
Installed OR NOT NEW_VERSION_FOUND
</Condition>
<InstallExecuteSequence>
<RemoveExistingProducts Before="InstallInitialize" />
</InstallExecuteSequence>
</Product>
However, despite putting in a <upgrade> element for the old installer's upgrade code, the old version isn't getting removed. As a result the new copy tries to install on top of the old copy, and then neither version works any longer.
The detection of the beta copy, and of newer versions, works correctly (the <Upgrade with GUID {43e024b8-b3ea-40a3-a854-2af83f207f0f} ). The beta version gets uninstalled, and if I generate a "newer" installer, then the current installer correctly doesn't install. That is, the WiX installers have no problem detecting each other.
Is there something I did wrong here that won't let it detect the old .vdproj installed copies?
EDIT: I tool a log of the installation process when this happens, I get the following:
Action start 17:25:47: FindRelatedProducts.
MSI (c) (10:B8) [17:25:47:269]: FindRelatedProducts: current install is per-machine. Related install for product '{2024FF03-D6F2-4065-A22B-80252B2A66B6}' is per-user. Skipping...
Action ended 17:25:47: FindRelatedProducts. Return value 1.
which appears to be accurate. The old installer gave an option for "Per User" or "Per Machine", whereas the new installer always forces per machine. If I select "Everyone who uses this computer" in the old installer, then the new installer is able to detect it. I would like to detect either option if possible in the WiX.
I'm afraid you can't deal with 2 different existing installations at the same time in single installer. Moreover you shouldn't try to run uninstallation of another product (since your UpgradeCode and ProductCode are different, it is anoter product) because msi can't work with simultaneous installations.
What I would recommend is creating separate exe application (bootstrapper), which will run child uninstallation processes of previously installed products and then immediately run your product's installation (probably in full UI mode).
To uninstall the product with no user interaction, use the following command:
msiexec /x {ProductCode} /qn
I hope you know the ProductIds of the previously installed products. If not, you can find it, searching the registry:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\{ProductCode}\DisplayName
and HKEY_CURRENT_USER if application was installed for single user.
{ProductCode} mentioined in registry path is GUID which is your productCode. You should retrieve all nodes in "Uninstall" branch and find those which are your products checking the "DisplayName" attribute. I hope you know at least the name of the products installed =). And be careful not to delete all software on client's machine =)
Please note if you installed x86 application on x64 machine, you should search location
HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{ProductCode}\DisplayName"
One more important notice: if your bootstrapper will be also x86 application, you should retrieve node without "Wow6432Node" node because it will be automatically inserted in the requested path. Wonderful world of registry keys on different platforms =).
Please ensure your bootstrapper will be run with admin permission or will ask permission elevation (it should contain security manifest).
One assumption about problem in your post: maybe you didn't change the ProductCode when changed the UpgradeCode? I'm not sure how it will behave, but it is definitely not a MajorUpgrade which automatically removes the previously installed product. For more details see Wix documentation on upgrades. So you might got Minor upgrade or patch which directly installs new components on top of the previously installed files. That definitely could break the application.