It is actually simple and one of the discussions here covered that task exactly. Unfortunately cannot find it.
Anyway during the first install (after InstallExecute) you need to save [INSTALLDIR] into the registry somewhere. If you use ManagedAction it's straightforward, if WiX then you have to ensure that regvalue is not removed on uninstall, which is a first step of upgrading. In the new version msi ensure (on AppSearch stage) read regvalue into [INSTALLDIR] property. Again it's obvious how to do in ManagedAction but if you rely on WiX only then you will need to use RegValueProperty (RegistrySeearch sample).
Anyway during the first install (after InstallExecute) you need to save [INSTALLDIR] into the registry somewhere. If you use ManagedAction it's straightforward, if WiX then you have to ensure that regvalue is not removed on uninstall, which is a first step of upgrading. In the new version msi ensure (on AppSearch stage) read regvalue into [INSTALLDIR] property. Again it's obvious how to do in ManagedAction but if you rely on WiX only then you will need to use RegValueProperty (RegistrySeearch sample).