Wix action FindRelatedProducts not working - wix

This could be a stupid question.
What we did
We just want to use FindRelatedProducts action to check existing installation's version, by following Wix tutorial:
<Upgrade Id='YOURGUID-7349-453F-94F6-BCB5110BA4FD'>
<UpgradeVersion OnlyDetect='yes' Property='SELFFOUND'
Minimum='1.0.1' IncludeMinimum='yes'
Maximum='1.0.1' IncludeMaximum='yes' />
<UpgradeVersion OnlyDetect='yes' Property='NEWERFOUND'
Minimum='1.0.1' IncludeMinimum='no' />
</Upgrade>
...
<CustomAction Id='AlreadyUpdated' Error='Foobar 1.0 has already been updated to 1.0.1 or newer.' />
<CustomAction Id='NoDowngrade' Error='A later version of [ProductName] is already installed.' />
<InstallExecuteSequence>
<Custom Action='AlreadyUpdated' After='FindRelatedProducts'>SELFFOUND</Custom>
<Custom Action='NoDowngrade' After='FindRelatedProducts'>NEWERFOUND</Custom>
</InstallExecuteSequence>
What we get
if no version was installed, FindRelatedProducts can detect that no installation exists, but
if 1.0.1 exists, when install 1.0.0, existing installation with higher version number should be detected, and err msg pop up, but it doesn't.
We used Orca to check the installation entry info on .msi files (1.0.0 and 1.0.1), properties of both are correct.
We used msiexec /a foo_1.0.x.msi /l* foo_1.0.x.log to get the log, but found the NEWERFOUND property is NOT set!
What we did wrong?

Make sure the UpgradeCode is the same for both 1.0.0 package and 1.0.1 package and in Upgrade/#Id attribute.

YES, I have try the example from WiX tutorial, replace YOURGUID*** with real GUID, the example doesn't work, I still can install old version over the new version, the downgrade check mechanism seems do not work.

Related

Wix Installer detecting SELFFOUND when should be PREVIOUSFOUND

I have a strange issue whereby WiX Installer appears to be detecting a SELFFOUND instead of a PREVIOUSFOUND.
I am moving an old InstallAware project over to WiX so I have copied the UpgradeCode from the project to this Product.wxs
<Upgrade Id='MyGuid'>
<UpgradeVersion OnlyDetect='yes' Property='SELFFOUND' Minimum='!(bind.FileVersion.MainEXE)' IncludeMinimum='yes' Maximum='!(bind.FileVersion.MainEXE)' IncludeMaximum='yes' />
<UpgradeVersion OnlyDetect='yes' Property='NEWERFOUND' Minimum='!(bind.FileVersion.MainEXE)' IncludeMinimum='no' />
<UpgradeVersion Minimum="1.0.0"
IncludeMinimum="yes"
OnlyDetect="no"
Maximum="!(bind.FileVersion.MainEXE)"
IncludeMaximum="no"
Property="PREVIOUSFOUND" />
</Upgrade>
<CustomAction Id='AlreadyUpdated' Error='[ProductName] is already installed.' />
<CustomAction Id='NoDowngrade' Error='A later version of [ProductName] is already installed.' />
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallInitialize"/>
<Custom Action='AlreadyUpdated' After='FindRelatedProducts'>SELFFOUND</Custom>
<Custom Action='NoDowngrade' After='FindRelatedProducts'>NEWERFOUND</Custom>
</InstallExecuteSequence>
and the Upgrade GUID matches that in my Product tag of the UpgradeCode attribute. The product codes between the two versions is different but I don't think making these the same is a good idea.
The version installed by the old InstallAware project is 4.11.7311.0 and is visible in control panel with this version. The version I am trying to install via the Upgrade and remove the old version is 4.11.7314.0.
For some reason whenever I try to run the new WiX .msi it is throwing the [ProductName] is already installed message.
Am I missing something? Because everything seems correct to me. Thanks in advance. Wix Toolset v3.11.
Okay, so I found the problem, well there were multiple actually.
Firstly I ran the installer via command prompt to generate a log file.
msiexec /i "C:\Path\To\Installer.msi" /L*V "C:\ProgramData\Install.log"
I then searched this file for
FindRelatedProducts
and it found an application which was setting the SELFFOUND property, now I searched through the registry for the GUID and realised it was an old one from my testing, so I uninstalled this using
msiexec /x {FoundGuid}
Still having the issue at this point though, so repeated the process and found a message that said
FindRelatedProducts: current install is per-machine. Related install for product '{MyGUID}' is per-user. Skipping...
so all I had to do was change my InstallScope from perMachine to perUser and it detects correctly.

remove program from programs and features when installing newer version msi using wix

I am creating my installer msi using WIX.
My older application is already installed on machine when I am installing newer version of the application then it removes all files and assembly of older version and put newer version files and assembly but in programs and features of control panel shows both older and newer version.
I am using following code for upgrade
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion Minimum="$(var.ProductVersion)" IncludeMinimum="no" OnlyDetect="yes" Language="!(loc.lcid)" Property="NEWPRODUCTFOUND"/>
<UpgradeVersion Minimum="1.0.0.0" IncludeMinimum="yes" Maximum="$(var.ProductVersion)" IncludeMaximum="no" Language="!(loc.lcid)" Property="UPGRADEFOUND"/>
</Upgrade>
<CustomAction Id="PreventDowngrading" Error="!(loc.CustomAction_PreventDowngrading)"/>
<InstallUISequence>
<Custom Action="SetWindowsTypeProp" Before="FindRelatedProducts">1</Custom>
<!--Custom Action="SetPresenceProperties" After="SetWindowsTypeProp">1</Custom-->
<Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
</InstallUISequence>
<InstallExecuteSequence>
<Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
<RemoveExistingProducts Before="InstallInitialize"/>
</InstallExecuteSequence>
Please help me how to remove entry from programs and features
This means your MajorUpgrade isn't working. FindRelatedProducts isn't finding the older version and therefore REmoveExistingProducts isn't working. For recent versions of WiX you can remove a lot of this code and replace it with the newer MajorUpgrade element. It's a higher level abstraction that simplifies much of this authoring.
In order to have a successful MajorUpgrade several things have to happen:
1) Old and New MSI have to have the same UpgradeCode GUID. (Although it's technically possible for an MSI to remove unrelated Products by using additional UpgradeCode properties we'll ignore this for the purpose of this question.)
2) Old and New MSI must have unique ProductCode GUIDs.
3) New MSI must have a higher version ProductVersion property. Please note that only the first 3 numbers are evaluated. ( 1.2.3 -> 1.2.4 works 1.2.3.4 -> 1.2.3.5 does not )
4) Old MSI and New MSI must be installed in the same context ( Per User->Per User or Per Machine -> Per Machine )
5) Upgrade Table must be authored correctly. Use the MajorUpgrade element to assist in this.

How to copy a file only while major upgrade?

We need to copy a file only when majorupgrade. If fresh install happens it should not copy.
I tried to find File attribute and component attribute which would do it but found none.
How to allow a file to copy when major upgrade?
You need to write Custom action to copy the files.
<CustomAction Id="QtExecCopyPropertyFileCmd" Property="QtExec64CmdLine" Value=""[SystemFolder]cmd.exe" /c copy "[INSTALL_DIR]\Test.txt" "[BKP_DIR]\Test.txt""/>
<CustomAction Id="QtExecCopyPropertyFile" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="immediate" Return="check"/>
Check previous setup is installed or not using Upgrade property.
<Upgrade Id="{YOUR-GUID-HERE}">
<UpgradeVersion Property="PREVIOUSFOUND" Minimum="1.0.0" IncludeMinimum="yes" Maximum="$(var.Version)" IncludeMaximum="no" />
</Upgrade>
<Property Id="PREVIOUSFOUND" Secure="yes" />
Call the Custom action in Install Execute sequence. It will copy the files in Upgrades only.
<Custom Action="QtExecCopyPropertyFileCmd" After="AppSearch">(NOT Installed) AND (PREVIOUSFOUND<>"")</Custom>
<Custom Action="QtExecCopyPropertyFile" After="QtExecCopyPropertyFileCmd">(NOT Installed) AND (PREVIOUSFOUND<>"")</Custom>
You can have component Install Condition which check for existing product and then install. You can Check The following link Wix Conditionally Install Component if Registry Key Exists for more detail. There insead of filesearch you can do registry search also

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 installer Can't upgrade from previously installed Windows installer SW

I am creating a WIX installer for our software and now I have some issue when upgrading from previous Windows Installer packaged SW.
One thing before the problem, the upgrade from one WIX packaged SW to another WIX packaged SW is actually working fine, I am able to uninstall the older version and install the newer version. The real problem happens when the older version is Windows Installer packaged (which is our current solution) and the newer version is WIX packaged. Basically my WIX installer is unable to find out that a older version is already installed, so the newer version will be installed without uninstalling the old version.
How I make the connection between WIX installer and Windows installer: I set the UpgradeCode of WIX as the same as Windows installer one. I also check some examples online, and they suggest my current solution should work. Here is part of my .wxs file of the upgrade part:
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion OnlyDetect="yes" Minimum="$(var.VersionNumber)" Property="NEWPRODUCTFOUND" IncludeMinimum="no" />
<UpgradeVersion OnlyDetect="no" Maximum="$(var.VersionNumber)" Property="UPGRADEFOUND" IncludeMaximum="no" />
</Upgrade>
<CustomAction Id="PreventDowngrading" Error="A software with newer version number is found on this machine" />
<InstallUISequence>
<Custom Action="PreventDowngrading"
After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
</InstallUISequence>
<InstallExecuteSequence>
<Custom Action="PreventDowngrading"
After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
<RemoveExistingProducts After="InstallFinalize" />
</InstallExecuteSequence>
One thing might be worth mentioning is our SW is actually a Windows Service, I am not sure whether that matters. Thanks for any help!
Having the same upgradecode is not enough. You must also check that the two packages have the same install type, i.e. they both get installed per-user or per-machine. If the install type is different Windows Installer will skip the removal of the old version.