enigma
Posts: 89
Joined: Fri Jun 08, 2007 10:12 am

Let user configure App.Config/ Web.Config from Installation

I have a .Net application, and I have an App.Config ( or web.config) that hosts all the machine specific configuration ( such as connection string, database path, service life time etc). Since the value in App.config is the same for the life time of an application, so they need to be set only once.

The most natural way to do this, is to allow the user to set the values in App.Config after the all the files are properly placed on application folder, but before the installation completes. So, I need a custom action that
  1. Reads the App.Config file and load the default values into a dialog box
  2. lets user edit those values
  3. When OK is clicked, save those values back into App.Config file.
Does Advanced Installer support this out of box? If not, what's the best way to do this?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Let user configure App.Config/ Web.Config from Installation

Hi,

Unfortunately Advanced Installer cannot populate installer properties with XML entries. However, you could try this approach:
- on your custom dialog create the edit boxes
- for each edit box control set the "Property Name" and "Default Value" fields in the "Properties" pane
- in the "Files and Folders" page import the .config file as an XML
- with the XML editor modify the file to use the installer properties

Another approach to set the property values is to read them from the XML. However, this can be done only through a custom action.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
enigma
Posts: 89
Joined: Fri Jun 08, 2007 10:12 am

Re: Let user configure App.Config/ Web.Config from Installation

Hi cosmin,
for each edit box control set the "Property Name" and "Default Value" fields in the "Properties" pane
Thanks, but I wonder how to pass the value to the App.Config, which is located in my Application folder?
with the XML editor modify the file to use the installer properties
Actually, I can't find the XML editor :( , let alone using it to configure the App.Config setting. Is there any pointers?

I would appreciate a step-by-step ( as detailed as possible, with pictures preferably) guide, thanks.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Let user configure App.Config/ Web.Config from Installation

Hi,

In the "Files and Folders" page you can use the "Import XML Files" context menu or the "Import" -> "XML Files" toolbar button to import an XML file into the project. After the import, you can double-click the file or use it's "Properties" context menu to edit it. You can read more about the editor here.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
enigma
Posts: 89
Joined: Fri Jun 08, 2007 10:12 am

Re: Let user configure App.Config/ Web.Config from Installation

I afraid I didn't express my intention properly. Here's how I setup the App.Config:
Image

And here's how I setup the dialog box to edit App.Config.
Image
However, I couldn't finish installing the package because it hanged there at my custom dialog.

Anything I miss?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Let user configure App.Config/ Web.Config from Installation

Hi,

For paths it is recommended to use "Path Edit" controls instead of edit boxes. Also, the path edit control should use a public property instead of a private one. If the problem persists after making these modifications, please send us the AIP you are using to support at advancedinstaller dot com so we can investigate it.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Grega
Posts: 24
Joined: Tue May 12, 2009 2:26 pm

Re: Let user configure App.Config/ Web.Config from Installation

Hi,
I will borrow this thread since its something I am trying to figure out right now.

1.I have a custom dialog where user enters a DataBasePath which will be then inserted into app.config file. I created the custom dialog by adding the new dialog and copied controls from the filepath dialog... Public property for Datapath is APPDIR_1.

2. I added the .config file as an XML file and I can Edit it in XML editor, but I have no idea how to put the value from APPDIR_1 to the "text" in "Element Settings" tab (I suppose this is where it should go right)?

One more thing If I want to put a default path value in the path text box on the custom dialog like c:\Documents and Settings\[User name]\My Documents\ how can I get the "User name"?

Thanks for any help...

Regards
Greg
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Let user configure App.Config/ Web.Config from Installation

Hi Greg,
I have no idea how to put the value from APPDIR_1 to the "text" in "Element Settings" tab (I suppose this is where it should go right)?
The "Text" field is formatted, so it can contain any formatted element, including your custom property. The reference to the property can look like this:

Code: Select all

[APPDIR_1]
This field should be set to the element text.
If I want to put a default path value in the path text box on the custom dialog like c:\Documents and Settings\[User name]\My Documents\ how can I get the "User name"?
You can get the current user name from the USERNAME property. Unfortunately the value of a path edit control cannot contain an installer property when set in the "Dialogs" page. However, you can try using a Property set with formatted custom action or SetProperty control event to set the property of the path edit to the path you want.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Grega
Posts: 24
Joined: Tue May 12, 2009 2:26 pm

Re: Let user configure App.Config/ Web.Config from Installation

Hi Cosmin,

Thank you for your help, I worked it out so installer now changes the path in the app.config file.

I still have some problem with default path...
cosmin wrote: You can get the current user name from the USERNAME property. Unfortunately the value of a path edit control cannot contain an installer property when set in the "Dialogs" page. However, you can try using a Property set with formatted custom action or SetProperty control event to set the property of the path edit to the path you want.
I added the Custom action (property set with Formatted) in the install sequence. I named it DEFAULTDATAPATH, with formatted text : [PersonalFolder]\MageeSci\AE51 Data.

Now I am not sure how to get this property shown in path edit control. I put property in default value but an window with "Installer information" saying "The specified path 'DEFAULTDATAPATH' is unavailable." occurred during installation.

Thanks for help,

Greg
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Let user configure App.Config/ Web.Config from Installation

Hi Greg,

The property which contains the path (DEFAULTDATAPATH) can be set as the property of the path edit control (in the "Property Name" field from the "Properties" pane of the control). This way, the value of the property will be shown in the control.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Grega
Posts: 24
Joined: Tue May 12, 2009 2:26 pm

Re: Let user configure App.Config/ Web.Config from Installation

cosmin wrote:Hi Greg,

The property which contains the path (DEFAULTDATAPATH) can be set as the property of the path edit control (in the "Property Name" field from the "Properties" pane of the control). This way, the value of the property will be shown in the control.

Regards,
Cosmin
Hi Cosmin,

I guess I am doing something wrong, I get the default value that is in the property field of properties of path edit control...or error if there is nothing in there.

This is what I do I set the custum action like this:
Image

And in the dialog like this:
Image

Thank you for all the help.

Greg
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Let user configure App.Config/ Web.Config from Installation

Hi Greg,

Please note that the custom action should run before the installation dialogs are shown. For example, you can scheduled it under "InstallUISequence" -> "Begin". You can show the "Begin" standard action by using the "Show Standard Action" toolbar button or context menu in the "Custom Actions" page.

Also, the path edit control should not have a default value.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Grega
Posts: 24
Joined: Tue May 12, 2009 2:26 pm

Re: Let user configure App.Config/ Web.Config from Installation

That did it :)

I knew that custom action was supposed to run before dialog is shown, but I thought that install is run before that.

Anyway thanks a lot!

Greg
aahkam
Posts: 1
Joined: Mon Oct 26, 2009 9:21 am

Re: Let user configure App.Config/ Web.Config from Installation

Hi,

I'm new to advanced installer. I'm using Advanced Installer 7.2.1 under Windows Server 2008 (x86).

I created an Advanced Installer project (*.aip) and created a windows installer property (ServerName) with default value "localhost".

I added my configuration as regular file and imported the same file as the xml file for editing/updating purposes using the ServerName windows installer property created earlier on.

I have created a UI dialog with a SimpleEdit control having its property set to ServerName. This would allow user, during setup/installation, changing the values to be fed to the configuration file.

Now that I run the installer, it completed successfully but the changes (user input) was not reflected in the configuration. The configuration is still remain at its (ServerName) windows installer property default value.

Please advise...

pls: Attached a sample aip project in the zip.

aahkam
Attachments
Testing.zip
AIP project containing only config file.
(233.7 KiB) Downloaded 616 times
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Let user configure App.Config/ Web.Config from Installation

Hi,

Please note that private properties do not pass their values from the UI sequence (when the dialogs are shown) to the execute sequence (when the files are created). Try using a public property (for example SERVERNAME) and let me know if the problem persists.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”