Search code examples
.netwindows-installersetup-projectcustom-action

Setup project + custom actions: retrieving old version number during upgrade installation


The situation is this:

I have a Setup project created for my .NET application, which is using special assembly with some custom actions defined, that are called during installation. The setup project is set to detect previous installations and do automatic upgrade, if there is an old version of application already installed on the machine.

What I would like to do is to detect through some custom action during installation process whether I am upgrading already installed version - and if this is true, from which version I am upgrading (it could be version of previously installed MSI package).

I tried to break into debugger at various points during installation (Install, Commit, Uninstall) and in each case, the older version was already removed from disk, so I haven't been able to get to the odl exe and read assembly version from it.

Is something like this even possible? Or it is already too late at the time custom actions are called?


Solution

  • unfortunately, this isn't possible with VS Setup project directly

    but you can use Orca for -- re-arranging your DetectOldVersionCA before 'RemoveFiles' or -- the best decision: add row to the 'Upgrade' table with the same UpgradeCode, the version moved from VersionMin to VersionMax and type in the 'ActionProperty' property name like (OLDFOUND) which will be set if old version of program is found