jbaynton
Posts: 15
Joined: Tue Jan 29, 2013 8:35 pm

Need to modify a config file during installation

I've written a custom action that needs to modify a number of config files (after Add Resources) based on various user selected installer properties (i.e. it needs to update connectionStrings).

My issue is in determining the path to these files. I understand that in a higher version of Advanced Installer, there is a modify text/XML feature, but that's not in the budget (currently using Professional) so I need to do it this way. Any help would be greatly appreciated.

Jeff
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Need to modify a config file during installation

Hello Jeff and welcome to Advanced Installer forums,

Thank you for your interest in Advanced Installer.

If your config files are added in "Files and Folders" page, then you can access their folder path using the folder identifier property (from "Folder Properties" dialog) within your custom action. So, you can extract the path from the related folder associated property in your custom action.

Let us know if this helps, otherwise give us more details about your scenario (maybe exemplify).

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jbaynton
Posts: 15
Joined: Tue Jan 29, 2013 8:35 pm

Re: Need to modify a config file during installation

Hi Daniel,

The scenario is as follows:

- During the Install Execution Stage:
- After "Remove Resources" I have a custom action that displays a form to gather and validate some information from the user
- After "Add Resources" I want to modify (via a custom action) some of the files added (that are added in "Files and Folders") with the user-provided information. NOTE: if this step could be done before adding the resources, that would be fine too.

My issue is that the folder's defined in the folder properties (or APPDIR) don't exist yet at that point (I'm assuming they're not actually created until the install is committed.)

Thanks,

Jeff
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Need to modify a config file during installation

Hello Jeff,

In order to achieve what you want you should add you add the related custom action after "Install Execution Stage -> Add Resources" action group. Also, the custom action should run as deferred.

If you have any questions let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jbaynton
Posts: 15
Joined: Tue Jan 29, 2013 8:35 pm

Re: Need to modify a config file during installation

Daniel.Radu wrote: Also, the custom action should run as deferred.
I was under the impression that running as deferred prevented my custom action from accessing installer properties.
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Need to modify a config file during installation

Hello,

Indeed, the deferred custom actions don't have direct access to installer properties. However, in order to access installer properties within deferred custom actions you can use the CustomActionData property. Also, you can take a look on our "How to add a custom action that modifies the system and accesses Installer Properties?" article.

If you have any questions let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”