I am writing a WIX installer with 2 requirements:
- implement an upgrade rules (which I did successfully with
<MajorUpgrade>
or<Upgrade>
table - keep a way to force installation of an old version in parallel of the current one (so do not upgrade).
Problem comes from the second requirement: if all versions of the app have the same UpgradeCode, the system will remove the old one (with the same UpgradeCode) avec install the new one.
So is it possible to upgrade old version (by default) and also let the user to force a parallel install ? One solution I have is to change the UpgradeCode when installing the MSI. In this case 2 versions will be completly independant, that's what I would like.
But I did not find a way to specify another UpgradeCode at installation stage. I tried msiexec /i app.msi UpgradeCode="{60C200E9-E317-4a67-9CC1-7BF156DEF4FD}"
, but according to the logs it gets properly the UpgradeCode property but still use the GUID specify when building the MSI.
Any idea how to force an UpgradeCode when installing a MSI ?
For info, my Wix file is composed like this:
<?define ProductUpgradeCode = "32318521-631C-4064-88C6-4A54FAA3B383"?>
[...]
<Product Name='App' Id='*' UpgradeCode='$(var.ProductUpgradeCode)'
Language='1033' Codepage='1252' Version='1.0.0' Manufacturer='App inc'>
[...]
<MajorUpgrade AllowDowngrades="yes" Schedule="afterInstallInitialize" />
Edit - Solution, based on Ciprian's answer:
First, define an ALLOWUPGRADE
property with default value to Yes
:
<Property Id="ALLOWUPGRADE" Value="Yes" />
Then, condition the action in <InstallExecuteSequence>
, so it only uninstall older versions if ALLOWUPGRADE=Yes
:
<RemoveExistingProducts After="InstallFinalize">ALLOWUPGRADE="Yes"</RemoveExistingProducts>
And, even better, add a dialog asking the user if he wants to upgrade or make a parallel installation. A button ParallelInstallBtn
will change property value to No
. This dialog will be called after FindRelatedProducts
if an older version is detected by a UpgradeVersion
section:
<UI>
<Dialog Id="InstallDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
[...]
<Control Id="ParallelInstallBtn" Type="PushButton" X="280" Y="243" Width="80" Height="17" Default="no" Text="&Parallel Install">
<Publish Property="ALLOWUPGRADE" Value="No">1</Publish>
<Publish Event="EndDialog" Value="Return">1</Publish>
</Control>
</Dialog>
<InstallUISequence>
<Show Dialog="InstallDlg" After="FindRelatedProducts">OLDERVERSIONBEINGUPGRADED</Show>
</InstallUISequence>
</UI>