wixwindows-installerorcamsi-patch

WiX: Change .msi Directory and CustomAction table with changes to be used by .msp Patch file


with the Wix Toolset v3.11 I have created a .msi file for my application (let's say version 1.1) with a Directory element that targets the LocalAppDataFolder and puts a Temp folder underneath. This structure is used with a DirectoryRef element to put some files there that are accessed within a custom action on InstallFinalize. Now I generated a Patch (version 1.2) that adds some files in the Temp folder. But I want that folder to be in the TARGETDIR now. So I changed

<Directory Id="LocalAppDataFolder">
  <Directory Id="APPDATA_TEMP" Name="Temp" />
</Directory>

to

<Directory Id="MY_TEMP_PATH" Name=".">
  <Directory Id="APPDATA_TEMP" Name="Temp" />
</Directory>

underneath the

<Directory Id="TARGETDIR" Name="SourceDir">

structure. For the Patch to be applied correctly I opened the .msi file that's referenced in the registry (under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\...\Products{GUID}\InstallProperties\LocalPackage) with the Orca tool and edited the corresponding values in the Directory table. I also edited the CustomActions table to reference the new path as it is used as a parameter there. So, now when I install the Patch it puts all the files (changed and new ones) in the LocalAppDataFolder as it did with the initial install. The custom action is called with the correct parameter though.

Is there a way to change the "base" msi to target my new Temp folder or, alternatively, somehow tell the Patch to use the new folder regardless of the initial path?

The goal is to apply the patch without having to uninstall the application first.

Any help on how to achieve that is greatly appreciated.


Solution

  • Finally we found a solution. So here's what solved our problem, should anyone ever come across something similar:

    We found the actual path of the LocalAppDataFolder in two locations in the registry: The first entry is located in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Folders. The second one is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData...\Components. The entry with the component ID that puts the files in the Temp folder holds exactly one value, which is the path to the first file in that component. We changed both paths to our new temp folder.

    Now the patch extracts the files correctly to the new temp folder and the custom action can process them further.