Message-ID: From: "chrullrich (@chrullrich)" To: "postgresql-interfaces/psqlodbc" Date: Sun, 29 Sep 2024 17:54:56 +0000 Subject: [postgresql-interfaces/psqlodbc] issue #57: MSI upgrades leave files behind List-Id: X-GitHub-Author-Id: 4695907 X-GitHub-Author-Login: chrullrich X-GitHub-Issue: 57 X-GitHub-Repo: postgresql-interfaces/psqlodbc X-GitHub-State: closed X-GitHub-Type: issue X-GitHub-Url: https://github.com/postgresql-interfaces/psqlodbc/issues/57 Content-Type: text/plain; charset=utf-8 I just noticed that a previous upgrade of psqlODBC left some files behind in the installation directory, specifically the OpenSSL 1.1 libraries (libssl-1_1 and libcrypto-1_1). The reason is that the MSI packages violate the holy writ of Windows Installer, also known as the "component rules". The gist of those is that whenever the contents of a component (`` in WiX) change, the component's GUID must also change. See, e.g., https://learn.microsoft.com/en-us/visualstudio/extensibility/internals/windows-installer-basics and https://robmensching.com/blog/posts/2003/10/18/component-rules-101/. Because the component codes are hardcoded and have not changed in a long time, and because the packages are authored so `RemoveExistingProducts` happens after `InstallFinalize`, that action never does anything. The set of components installed on the system does not change across the installation as far as Windows Installer is concerned, so `RemoveExistingProducts` does nothing. Any preexisting files that are not in the new version of the package are left behind. There are two possible fixes, listed here in order of preference: 1. Do not hardcode the component codes, but leave them up to WiX. (While you're at it, do not hardcode anything else but the upgrade codes either.) 2. Schedule `RemoveExistingProducts` after `InstallInitialize`. This will remove the old files before installing the new ones. See https://wixtoolset.org/docs/v3/xsd/wix/majorupgrade/ for more information on scheduling this action.