I have an application which I am writing a major upgrade for.
The only thing that is persistent is an UpgradeCode
.
What I want is to use a location of a previously installed version as a default path for installation.
My naive solution is to run a CustomAction which modifies the INSTALLDIR
with a variable APP_LOCATION
obtained by AppSearch
table.
INSTALLDIR = APP_LOCATION ? APP_LOCATION : MY_DEFAULT_INSTALL_DIR
(syntax is to emphasize the logic, idk if is valid)You can fetch previous install location using the following method:
Msi.GetProductInfo(ProductCode of previous Install, "InstallLocation");
To get the product code of previous installation, Use the public property set for the major upgrade. This public property for example OLD_PRODUCT_DETECTED property can be found in ActionProperty column of Upgrade table. It's value will be set to product code({GUID}).
Make sure to call the above method after FindRelatedProducts action which sets the value for public property to {GUID} if previous installation found.