1

I have an .msi installer, that places several files. After a version update the files got new GUIDs, and now when updating from version 1 to 2 the installer deletes some of these files instead of updating them.

Looking at the log it calls register component for the file with the new ID, but there is a message I suspect might be the reason:

File: <PATH_TO_FILE>; Overwrite; Won't patch; Existing file is unversioned and unmodified - hash doesn't match source file

How do I ensure that files with the new GUIDs are copied over the older versions (make them versioned)?

UPDATE:

I tried setting ReinstallMode to "amus", rather then "omus", but it seems like since the previous .msi was "omus" the files still disappear, unless I run the new installer twice in a row, which isn't optimal.

Essentially I need a version 3 installer that can upgrade version 1 or 2 and not delete the files in question (if that's possible)

Maxim
  • 335
  • 5
  • 14
  • What tool are you using? WiX? Essentially you need to keep the component GUIDs stable between releases. You can use WiX's auto-GUIDs to do so (auto-generated GUIDs). You also must break the link to the past sins so I suggest setting a new main installation path. This will work, but you have to determine if it is OK for your product. How large is it? Do you have settings files that must be preserved in the new version? – Stein Åsmul Aug 27 '18 at 22:58
  • @Stein Åsmul Changing the install location and GUIDs is unfortunately not possible. Changing the GUIDs back would just create the same problem between Version 2 and 3 – Maxim Aug 28 '18 at 15:53
  • Can I ask where `RemoveExistingProducts` is located in the `InstallExecuteSequence` in your final, compiled MSI? Open in Orca, check the `InstallExecuteSequence` table, sort by `Sequence column`. What is the action immediately preceding `RemoveExistingProducts`? (and what is the sequence number). – Stein Åsmul Aug 29 '18 at 03:38
  • @Stein Åsmul Right before `RemoveExistingProducts` (6601) is `InstallFinalize` (6600) – Maxim Aug 29 '18 at 14:38

1 Answers1

2

Quick Fix: I have added this summary section at the top, but please read the below details sections as well. You are experiencing the common problem of messed up component reference counting, and this is causing these upgrade problems you are seeing. Component GUIDs are to remain stable across releases as long as the key path does not change (and it never should change - if it does then you need a new component GUID - explanation below).

Early REP: Rather than fixing the real problem, there might be a way to deal with it that is less than ideal, and that is to use "Early REP" as we call it. Essentially you move RemoveExistingProducts in the InstallExecuteSequence before InstallInitialize. This will fully uninstall the old version and then install the new one with all its files (generally) - without interference. You decouple the new version from past sins. This can be done using Orca or an equivalent free tool (bottom) to hotfix your compiled MSI (change sequence number in the InstallExecuteSequence table) or it can be done in your source files - whichever tool you are using.


Component Reference Counting: Erroneous component GUIDs and thereby reference counting for MSI components is a very bad thing - it has to be said. The component / key path concept is at the heart of much of MSI itself - how it deals with file updates and maintenance and reference counting. The concept is essentially that for every absolute key-path there is supposed to be a single component GUID, shared by all packages targeting that location. There are some more details here: Change my component GUID in wix?

WiX Auto-component GUIDs: If you are using WiX (which we don't know if you do), then I would propose that you use WiX's auto-GUID concept whereby a component GUID is calculated based on the installation key path as opposed to being hard coded in your WiX source (or generated by your build process). This WiX algorithm will take care of reference counting in an "auto-magic" fashion.

This answer tries to explain the rationale behind WiX auto-component GUIDs and how it can benefit you: Syntax for guids in WIX? Not all installation locations allow component GUIDs to be auto-generated, but for the most part it is a comprehensive "auto-magic".

Code Sample: When using auto-component GUIDs you do not specify a GUID in your source:

<!-- Sample guid below, do not copy paste -->
<Component Id="File.dll" Guid="{12345678-1234-1234-1234-123456789ABC}">
  <File Id="File.dll" Name="File.dll" KeyPath="yes" Source="..\File.dll" />
</Component>

versus auto-component GUID:

<Component>
  <File Source="..\File.dll" />
</Component>
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164