WIX remove previous version and install new version - wix

I'am using WIX and losing my hair very quickly!
So I have my application installed on my pc - the version number is 1.1.1.0. I wish to install my new version (1.1.2.0) AND remove the previous version at the same time. I have gone through a few tutorials and have basically been trying trail and error to get this to work but cannot.
Below is my code I can't see what exactly I am missing though?
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define ProductName="Order Entry"?>
<?define ProductCode="4e447072-689e-4641-ad60-8ae18f1bfcf0"?>
<?define UpgradeCode="27cb76c7-544e-465f-b1f3-b11d9a49e416"?>
<?define RTMProductVersion=1.1.1.0?>
<?define ProductVersion=1.1.2.0?>
<Product Id="$(var.ProductCode)"
Version="$(var.ProductVersion)"
Name="$(var.ProductName)"
Language="1033"
Manufacturer="MyCompany"
UpgradeCode="4e447072-689e-4641-ad60-8ae18f1bfcf0">
<Package InstallerVersion="300" Compressed="yes" InstallScope="perMachine" />
<Media Id="1" Cabinet="myCab.cab" EmbedCab="yes" CompressionLevel="medium" />
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion Minimum="$(var.ProductVersion)"
IncludeMinimum="no"
OnlyDetect="yes"
Language="1033"
Property="NEWPRODUCTFOUND"/>
<UpgradeVersion Minimum="$(var.RTMProductVersion)"
IncludeMinimum="yes"
Maximum="$(var.ProductVersion)"
IncludeMaximum="no"
Language="1033"
Property="UPGRADEFOUND"/>
</Upgrade>
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallInitialize"/>
<!-- <InstallExecute After="RemoveExistingProducts" />-->
</InstallExecuteSequence>

Related

Where in Bundle set InstallPrivileges = "elevated". Bootstrapper Wix

I find to set administration privilages for Wix installer you have to set:
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated"/>
in <Product/>. But where/how set that for Bundle, because I cant create <Package/> ?
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Bundle Name="Bootstrapper13" Version="1.0.0.0" Manufacturer="" UpgradeCode="86064926-b150-448f-aba9-fb0c8f4a83b5">
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />
<Chain>
<!-- TODO: Define the list of chained packages. -->
<!-- <MsiPackage SourceFile="path\to\your.msi" /> -->
</Chain>
</Bundle>
Burn automatically detects when you have a perMachine package; you don't have to tell it.

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>

No uninstall on Wix major upgrade

Here's my code:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define ProductName = "MyApp"?>
<?define ProductCode = "GUID_NO1"?>
<?define UpgradeCode = "GUID_NO2"?>
<?define ProductVersion = "1.0.0"?>
<Product Id="$(var.ProductCode)"
Name="$(var.ProductName)"
Language="1033"
Version="$(var.ProductVersion)"
Manufacturer="Me"
UpgradeCode="$(var.UpgradeCode)">
<Package Description="My desc"
InstallerVersion="300"
Compressed="yes"
InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version is already installed." />
...
I build, install and all goes fine.
So I replace
<?define ProductCode = "GUID_NO3"?>
<?define UpgradeCode = "GUID_NO4"?>
<?define ProductVersion = "1.0.1"?>
I build, install and in programs/features i found 2 MyApp, one in version 1.0.0 and one in verison 1.0.1.
Of course I need the 1.0.0 to be removed.
Keeping the same guid for ProductCode will not work.
I'm using Wix 3.8.
Make sure that the UpgradeCode remains the same and change the Id to *.
<Product Id="*" Name="Stub" Language="1033" Version="$(var.Version)"
Manufacturer="" UpgradeCode="FAFD7276-68F3-43AF-BEBF-8F175499A243">

WiX: Conditionally including UpgradeCode in WiX file

I'm using WiX to build an installation package for a product at my company and I want to be able to build two slightly different versions of the .msi depending on if it is meant to be used internally in the company for testing or externally for customers.
The internal version should be built with no UpgradeCode, so that we can have several versions installed at the same time for comparison. The external version should have a static UpgradeCode.
WiX does not allow me to have UpgradeCode auto generated by doing this:
<?if $(var.Configuration) = "Internal Release"?>
<?define UpgradeCode = "*"?>
<?else?>
<?define UpgradeCode = "[REALGUID]"?>
<?endif?>
<Product ... UpgradeCode="$(var.UpgradeCode)">
To have the UpgradeCode "auto generated" you have to completely ommit the UpgradeCode attribute.
Anyone have any suggestions on how to accomplish this?
Probably you can't use * for Upgrade Code (i'm not sure) but you could pass it as property through msbuild which i do for ProductCode conditionaly (if we are building patches or not)
<UpgradeCode Condition="$(InternalRelease)==1">{$([System.Guid]::NewGuid().ToString().ToUpper())}</UpgradeCode>
In your msbuild.proj add that property in your Target/msbuild project/Properties.
Add UpgradeCode=$(UpgradeCode) in you constants (wixproj)
Then in your main wxs add something like this:
<?if $(var.UpgradeCode)=""?>
<?define UpgradeCode=your-static-upgradecode ?>
<?endif?>
So if the project receives the upgrade code then it will use that one otherwise will be your fixed upgrade code in defined.
And finally to generated the guid call the msbuild.proj with /p:InteralRelease=1
Adding this answer as an alternative solution for other users with the same challenge.
Altough IlirB's answer probably would work as expected (I haven't tried it as I solved the problem with my own solution before the answer was provided), I solved the problem by conditionally including one of 2 different versions of the Product-tag. Of which only one had the UpgradeCode defined.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include Config.wxi?>
<?if $(var.IsExternalRelease) = yes?>
<Product Id="$(var.ProductID)" Name="$(var.ProductName)" Language="1033" Version="$(var.Version)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)">
<Package Id="$(var.PackageID)" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes"/>
<PropertyRef Id="AllProperties"/>
<UIRef Id="CUSTOM_UI"/>
<FeatureRef Id="F_AllFeatures"/>
</Product>
<?else?>
<Product Id="$(var.ProductID)" Name="$(var.ProductName)" Language="1033" Version="$(var.Version)" Manufacturer="$(var.Manufacturer)">
<Package Id="$(var.PackageID)" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MediaTemplate EmbedCab="yes"/>
<PropertyRef Id="AllProperties"/>
<UIRef Id="CUSTOM_UI"/>
<FeatureRef Id="F_AllFeatures"/>
</Product>
<?endif?>
</Wix>
Because I made an effort in splitting the wix code into several pieces and referring them from the Product tag, there was not much duplication of code.

Wix - Upgrade will old installation and install new one

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.