28

I have CI build system builds an MSI whenever a developer checks in a change. We run automated acceptance tests on the installed MSI.

Basically every MSI is a complete install of the product, so we don't have any versioning (ala Windows installer) per se..

Each MSI has the same product GUID and upgrade GUID, and the same version number. but has a different package GUID (use '*' in wix).

What I want to achieve is that when the installer runs, it will 'uninstall' any previously installed version of the product, and install the new one.. all from a single MSI (We have a convoluted install process that is out of our control.. citrix and sccm, so we want to give them a simple install path)

I have tried:

<Property Id='PREVIOUSVERSIONSINSTALLED' Secure='yes' />
<Upgrade Id='$UPGRADE_GUID'>  
  <UpgradeVersion Minimum='1.0.0.0'
                  Maximum='99.0.0.0'
                  Property='PREVIOUSVERSIONSINSTALLED'
                  IncludeMinimum='yes'
                  IncludeMaximum='no' />
</Upgrade>

and have:

<InstallExecuteSequence>
  <RemoveExistingProducts After='InstallFinalize' />
</InstallExecuteSequence>

and have tried:

<InstallExecuteSequence>
  <RemoveExistingProducts After='InstallInitialize' />
</InstallExecuteSequence>

But when I try to install an msi from a subsequent build I get:

Another version of this product is already installed. Installation of this version cannot continue. 
To configure or remove the existing version of this product, use Add/Remove Programs on the Control Panel. 

Which is not really what I was going for..

I understand that I can just update the Version attribute in the product tag, but that becomes difficult to manage. Firstly I can produce 20+ msi builds a day as I have a number of build pipelines that produce MSIs and am not sure how to handle the version numbering in a way that makes sense.

Maybe Windows Installer just does not allow this type of 'always overwrite installed version' install?

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
grillp
  • 1,273
  • 1
  • 11
  • 13

4 Answers4

30

So I did find a way of doing it without changing the version number.

I change the Product GUID with every build, but keep the Upgrade GUID the same.

I also had to change the RemoveExistingProducts to Before='InstallInitialize'. Otherwise it left only the 'deltas' between builds in the install path.

As noted by Wim below, I can replace the generated Product GUID with '*'.

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
grillp
  • 1,273
  • 1
  • 11
  • 13
30

You can use this code to remove the old version and install a newer one:

<Product Id="*"
         UpgradeCode="87795f3dc95-81f5-473e-955e-2871a5bd66a5"
         Name="AppName"
         Language="1033"
         Version="1.0.6"
         Manufacturer="Manufacturer Name">
  <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
  <MajorUpgrade Schedule="afterInstallInitialize"
                DowngradeErrorMessage="A later version of [ProductName] is already installed"
                AllowSameVersionUpgrades="yes" />
</Product>
lcsondes
  • 484
  • 4
  • 16
aa aa
  • 399
  • 3
  • 6
6

try

<InstallExecuteSequence>
  <RemoveExistingProducts After='InstallFinalize' />
</InstallExecuteSequence>

This should remove any existing products after the install is finalised though you could customize the point at which you do it

see http://mohundro.com/blog/2009/02/23/getting-started-with-wix-and-major-upgrades/

also see the accepted answer for this question

Community
  • 1
  • 1
Daniel Powell
  • 8,143
  • 11
  • 61
  • 108
  • Thx Daniel, That link is what I initially tried.. I forgot to mention that I had the RemoveExistingProducts already, but I had it with After='InstallInitialize'. I have now tried with After='InstallFinalize' and get the same result. :-( – grillp Jul 31 '12 at 04:18
  • 2
    @DanielPowell: According to your own link, it should've been `Before="InstallInitialize"` – c00000fd Feb 14 '16 at 04:15
4

If the product code and version are the same yet the package code is different, you will always get that Windows Installer error message.

I would strongly suggest including version information for your installers in your CI builds. If you are installing and subsequently upgrading each build, then versioning isn't a bad thing to have. It should be relatively easy to add this to a CI build.

BryanJ
  • 8,485
  • 1
  • 42
  • 61
  • Bryan, yeah I could do that.. Do you know what the limit is on eeh version numbers? is it 255.255.255.255 or is it larger than that? – grillp Jul 31 '12 at 04:23
  • See this link: http://msdn.microsoft.com/en-us/library/windows/desktop/aa370859(v=vs.85).aspx – BryanJ Jul 31 '12 at 04:25
  • 1
    I like to include the source control revision number as the third digit. – BryanJ Jul 31 '12 at 04:25
  • Thanks for that.. Like I said, I have a number of build pipeline, but only the result of the master build pipeline one ever goes into prod.. So I can just use the build number from that one.. The others are developer branches (Yech! multiple development branches merging to master.. don't ask!) so they can just be uninstalled and reinstalled manually. – grillp Jul 31 '12 at 04:34
  • BTW, Sorry about being lazy on the version numbers question.. should have just looked it up. – grillp Jul 31 '12 at 04:36
  • Another option may be to change the product code. I change the product code with every build, but like I said I always increment the version number. You may be able to just change the product code each time and edit your installer to be able to handle that upgrade. – BryanJ Jul 31 '12 at 04:38