0

I want to populate TARGETDIR based on the version of an Application that is already installed.

What I tried was adding multiple RegKey Launch Conditions, each checking the different RegKey the different versions of the App have used over the years but ALL setting TARGETDIR.

The idea is that if any matched it would set TARGETDIR - but that approach does not seem to work..

What is the best way of setting TARGETDIR when it can set on the basis of multiple RegKey entries?

I'm using VS2010 with an installer project.

1 Answers1

1

You do not need launch conditions, these are used to stop the installation, not to configure its installation parameters.

What you need is to use the registry to search for the version desired, then add custom actions that will set TARGEDIR property to the value desired, make sure you do this before CostFinalize, i.e. exactly after the searches are performed. Use as execution conditions for the custom action the registry searches, so only the custom action corespondent to the found version is executed.

Also, make sure you have a good default for users that have never installed a previous version, i.e. new users of your application.

Bogdan Mitrache
  • 10,536
  • 19
  • 34
  • OK, makes sense. So I populate many Properties for each version, and then I have to write a script to assign 1 of those Properties to TARGETDIR? Do I have that right? – Elektraglide Sep 09 '13 at 13:38
  • You can skip setting the properties, from the custom action you can directly set TARGETDIR to the desired value. Just make sure you set it based on the registry read from the machine and before CostFinalize is executed. – Bogdan Mitrache Sep 09 '13 at 13:50
  • Ah, looks like you cannot get an Install:Custom Action to run before CostFinalize from within VStudio. – Elektraglide Sep 09 '13 at 16:24
  • Indeed, VS is quite limited in what regards configuring the setup projects. You could add a post build event that changes the custom action sequence, this way you can set it to executed when desired: http://stackoverflow.com/questions/617409/script-to-change-action-sequence-records-in-an-msi/617415#617415 – Bogdan Mitrache Sep 09 '13 at 18:15