Search code examples
c#pathwix.net-2.0guid

From a GUID to a full path


I'm trying to get the location of an installation so that I can perform an upgrade, I am using a WiX installer but I cannot use WiX's own upgrade mechanics because it nukes the config files and does not do the checks that happen in the Custom Action's UI.

I have a bootstrapper which calls the .msi and I can easily get and set parameters within that .msi.

In this situation- how could I get from a known, but dynamic, GUID to the file location of its install within the bootstrapper before the .msi runs and nukes everything.

N.B. I cannot assume that the config file will remain the same between installs, or that I can grab the file faster than the uninstall can kill it.


Solution

  • You have quite a bit control over the upgrade mechanics that you should be able to do what you want during upgraded. In particular, I would have the new MSI read the config settings then write them back to the config file (your new MSI will definitely run before the old config file is removed). This would make your install idempotent (the ideal).

    To answer your question, there are a number of ways to do what you want. The following is how I would probably go about it:

    1. Write ARPINSTALLLOCATION - this old blog entry of mine has details.

    2. If you know the ProductCode of your old MSI, skip to step 3. If you do not now the ProductCode, then use the UpgradeCode of the MSI (you'll know that if you are doing upgrades at all) and use ::MsiEnumRelatedProducts() to find the ProductCode of your previously installed MSI.

    3. If you know the ProductCode of your MSI, then call ::MsiGetProductInfo() and ask for the INSTALLPROPERTY_INSTALLLOCATION property.