2
votes

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

1

1 Answers

3
votes

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.