I'm creating a Windows installer for my app using WIX, so, I start in the usual way:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="*" Name="Project X" Manufacturer="X LLC" Language="1033"
Version="1.0.0.1" UpgradeCode="PUT-GUID-HERE>
<Package InstallerVersion="301" Compressed="yes" InstallScope="perMachine"/>
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed."/>
Because the Id
is set to *
, every time I build an MSI it has a different id, but the UpgradeCode
remains the same. This successfully achieves replacing the old one with a new one when there's an upgrade in version (1.0.0.2 for example).
The MajorUpgrade
entry prevents a lower version, such as 1.0.0.0, from being installed.
If I run exactly the the same MSI file, it shows me a dialog to repair, uninstall or change the installation parameters.
My problem is that if I re-build the MSI, and run the new one, it installs as if there's no other copy of Project X installed and the user ends up with two entries in the Windows Apps & Features.
Is there a way to prevent that? Is there a way to prevent it without having to modify (and commit) my .wxs
file or another build file each time I build? I try to have my builds as automated as possible and having to open a file a change it each time would be really annoying.
Regarding passing the version number to candle.exe
, it doesn't solve the problem. That would still require storing the version number in the repo, creating commits for each test of the installer. It's the same problem whether I have to write the number manually in the wxs
file or I have to write the number manually in the pom.xml
(that's the build tool's config) or whether it's generating during build and stored on a file that then I have to commit to the repo so that the number keeps monotonically increasing for myself and all developers involved.
In case this matters, I'm using Git as my source control system, and Maven as my building tool, calling heat.exe
, candle.exe
and light.exe
. Specifically, I'm not using Visual Studio.
Regarding the similar question WIX. How to perform Major Upgrade with same version and different product code?, both the question and the answer assume it's ok to modify the .wxs
file to increment the version number each time you build an installer to test. I don't think it's acceptable. I already knew this was possible because this is what MajorUpgrade
does and I took note in this question.