Uninstalling another product during install using WiX - wix

I want to be able to remove another application as part of the install of my MSI file. Currently, I have the following in WiX:
<Upgrade Id="{586A589B-D6D5-48D3-9B6D-571EF230ED6A}">
<UpgradeVersion Minimum="$(var.ProductVersion)"
Property="NEWERPRODUCTFOUND"
OnlyDetect="yes"
IncludeMinimum="yes" />
<UpgradeVersion Minimum="1.0.0"
Maximum="$(var.ProductVersion)"
Property="PREVIOUSVERSIONSINSTALLED"
IncludeMinimum="yes" />
</Upgrade>
<Upgrade Id="{71F6B5D5-8CB9-48C9-B359-4BA22D5ADAF3}">
<UpgradeVersion Minimum="1.0.0.0"
Maximum="3.5.3"
Property="OLDAPPFOUND"
IncludeMinimum="yes"
IncludeMaximum="yes"/>
</Upgrade>
The first upgrade section is what upgrades my current MSI file (and this works). The second part is what I am trying to use to remove the other application (and this doesn't). Both the current MSI file and the one I am trying to remove both install in the per-machine context, so I cannot understand why this doesn't work. How can this problem be fixed?

A verbose log file should indicate what products are being detected by the Upgrade elements. From there it should be possible to track down the bug in your authoring.

Related

Configure WiX project to install multiple versions, but remove same minor version

I need to configure my WiX project to be able to install multiple minor versions of the product. IE: I can have 1.0, 1.1 and 1.3 installed. If I try to install 1.2, it will work, but if I try it with 1.1, it will uninstall the previous 1.1 installation before proceeding.
So far, this is what I have in my Upgrade tag:
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion Minimum="$(var.MajorMinorVersion)" IncludeMinimum="yes"
Maximum="$(var.VersionNumber)" IncludeMaximum="no" Property="OLDERMINORFOUND"/>
</Upgrade>
UpgradeCode is a guid defined in my wxi file and MajorMinorVersion is the same as VersionNumber, but with the build at 0 (1.1.0 when the version is 1.1.12).
I'm guessing that I have two possibilities:
I make another UpgradeVersion tag or update the current one to have the maximum at the next minor version and exclude it from the search:
<UpgradeVersion Minimum="$(var.MajorMinorVersion)" IncludeMinimum="yes"
Maximum="$(var.NextMinorVersion)" IncludeMaximum="no"/>
Using a custom action to set NextMinorVersion somehow. Maybe using a property instead.
Or, change the UpgradeCode manually each time the minor version changes. Or have the first few characters of the guid represent the version and the rest be unique? I doubt that's a good idea though...
So basically, what would be the best way to accomplish this, in the hopes of having only one setup project for all versions?
EDIT
I've looked into the MajorUpgrade tag, but I don't think I can configure it to have many minor versions at the same time. Any light on this is appreciated.
I've also looked into making a preprocessor extension that would manipulate the version number using functions, so I could do this:
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion Property="OLDERMINORFOUND"
Minimum="$(var.MajorMinorVersion)" IncludeMinimum="yes"
Maximum="$(myprefix.NextMinor($(var.VersionNumber)))" IncludeMaximum="no"/>
</Upgrade>
See my answer for details.
So I wrote an extension as per the WiX manual (Part 1 and Part 2).
I made a preprocessor extension that takes a version number string (ex: 1.2.3.4) and manipulates the version by parsing and splitting the string.
So now I can write this in my .wxs file:
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion Property="SAMEMINORFOUND" OnlyDetect="no"
Minimum="$(var.MajorMinorVersion).0" IncludeMinimum="yes"
Maximum="$(version.NextMinor($(var.VersionNumber)))" IncludeMaximum="no" />
<UpgradeVersion Property="OLDERVERSIONFOUND" OnlyDetect="yes"
Maximum="$(var.MajorMinorVersion).0" IncludeMaximum="no"/>
<UpgradeVersion Property="NEWERVERSIONFOUND" OnlyDetect="yes"
Minimum="$(version.NextMinor($(var.VersionNumber)))" IncludeMinimum="yes"/>
</Upgrade>
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallValidate"/>
</InstallExecuteSequence>
Where version.NextMinor is a call to my preprocessor extension.
So my installer will only detect installations of the product unless the minor versions match, where it will be uninstalled.

I have installed major upgrade successfully but it also allowing another previous version install in wix

I have installed major upgrade (say #206) successfully and included code as in (#206):
<Upgrade Id="$(var.ProductUpgradeCode)">
<UpgradeVersion Minimum="$(var.ProductVersion)" IncludeMinimum="no" OnlyDetect="yes" Language="1033" Property="NEWPRODUCTFOUND" />
<UpgradeVersion Minimum="1.0.0.178" IncludeMinimum="yes" Maximum="$(var.ProductVersion)" IncludeMaximum="no" Language="1033" Property="UPGRADEFOUND" />
</Upgrade>
Scenario is:
I have installed build #177 then upgraded to build #206. It is still allowed to install #177 which I want to prevent this downgrade.
From build #178 onward I have changed product GUID for major upgrade and which is working fine.
Please suggest how to prevent this. I don't want to downgrade build below 177. If I have done major upgrade on build no <= 177.
Your problem is the how the comparison of versions is done in MSI by default - 1.0.0.123 is treated the same as e.g. 1.0.0.33. You either have to increase your revision version to make the installer detect this as an older version or use a workaround.
You might for instance create a custom action to check against this very Revision version and place it e.g. before InstallValidate:
<CustomAction Id='MyVersionCheck' Return='check' (...) />
<InstallExecuteSequence>
<Custom Action='MyVersionCheck' Before='InstallValidate' />
</InstallExecuteSequence>
Some more information can be found in this article, for informations about how to create custom actions i'd recommend this blog entry as a starting point.

Wix: How to limit major upgrades to major version numbers?

I need the following behaviour from my wix-based installers:
Every setup in the major version 1.x.x line should majorupdate any
previous version of the 1.x.x line.
Every setup in the major version
2.x.x line should majorupdate any previous version of the 2.x.x line but
leave the 1.x.x line alone.
I though I could get this to work with the following code, but the setup removed the previous 1.x.x version. Am I mssing something? Is this even possible?
<Upgrade Id="myguid">
<UpgradeVersion OnlyDetect="yes" Minimum="2.0.0.1" Property="NEWERVERSIONDETECTED" IncludeMinimum="no" />
<UpgradeVersion OnlyDetect="no" Maximum="2.0.0.1" Property="OLDERVERSIONBEINGUPGRADED" IncludeMaximum="no" />
</Upgrade>
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallInitialize" />
</InstallExecuteSequence>
You need to use a NEW GUID for 2.x if you don't want it to be "aware" of 1.x (i.e. ignore it, don't care, etc)
I use the following code, only changing var.Property_UpgradeCode when I want a new version to ignore previously installed versions (e.g. exist side-by-side in different folders)
<Product Id="*"
UpgradeCode="$(var.Property_UpgradeCode)"
Name="!(loc.ApplicationName)"
Language="!(loc.Property_ProductLanguage)"
Version="$(var.version)"
Manufacturer="!(loc.ManufacturerName)" >
<MajorUpgrade AllowSameVersionUpgrades="yes"
DowngradeErrorMessage="!(loc.LaunchCondition_LaterVersion)"
MigrateFeatures="no"
Schedule="afterInstallInitialize" />
Put #Minimum and #Maximum attributes on a single UpgradeVersion element to specify a range. Author multiple UpgradeVersion elements to specify multiple version ranges.

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).

How to move user content in Wix Installer

To support Window Vista in my game, I have changed were the save files are placed (From under Program Files to My Documents) for both XP and Vista installations.
Now I would like to be able to move the current XP users save games from the old location to the new location.
I think I can correctly trigger this via the upgrade checking code like so:
<Upgrade Id="PLACE-GUID-HERE">
<UpgradeVersion OnlyDetect="yes" Minimum="$(var.ProductVersion)" IncludeMinimum="no" Property="NEWERVERSIONDETECTED" />
<UpgradeVersion OnlyDetect="no" Minimum="1.1.0" IncludeMinimum="yes" Maximum="$(var.ProductVersion)" IncludeMaximum="no" Property="OLDERVERSIONBEINGUPGRADED" />
<UpgradeVersion OnlyDetect="no" Maximum="1.1.0" IncludeMaximum="no" Property="MOVESAVEFILESUPGRADED" />
</Upgrade>
where 1.0.x was the old way and 1.1.x will be the new way, thus I could do something in a custom action based on MOVESAVEFILESUPGRADED, but the heart of the problem, I cant see how to move non-installed files from one location to another.
Use the CopyFile element. A custom action is overkill and VBScript custom actions are unreliable. See http://www.joyofsetup.com/2007/06/07/when-vbscript-and-jscript-custom-actions-are-even-more-evil/.
I dont think there is a built in custom action that will do that.If you write your own its best to use a dll, but vbscript or bat file will also do the job.
This might help