jdixon
Posts: 18
Joined: Sat Jan 04, 2014 8:50 pm

Possible to read the web.config during install?

I have a ASP.NET web application and during the installer you can put in the SQL information and it will populate the web.config file with the correct SQL connection string.

Is there a way to be able to read the web.config file when you start the installer and populate the SQL Fields I have in the installer with the information from the web.config file (if the web.config exists)? My installer shows the IIS applications, app pools, and then the next screen you fill out the SQL information. So before the SQL information they are selecting the IIS website and the AppPool.

Is this possible?
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Possible to read the web.config during install?

Hi,

Yes, to search the content of an XML file on install you can use our predefined support for XML search.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jdixon
Posts: 18
Joined: Sat Jan 04, 2014 8:50 pm

Re: Possible to read the web.config during install?

That does look like what i'm looking for!

However I do have an issue....

My SQL installer has text boxes for the server\instance, database name, username and password (or if using windows authentication). What it puts in the web.config file is the compiled connection string like this:

<add name="DB" connectionString="Data Source=SERVER\SQLEXPRESS;Initial Catalog=MYDATABASE;User Id=MYUSERNAME;Password=MYPASSWORD" providerName="System.Data.SqlClient" />

I need to pull this data out: SERVER\SQLEXPRESS, MYDATABASE, MYUSERNAME, and MYPASSWORD and not the whole data in the connectionString value. I'm not finding where this is possible to parse the data and place them in specfic text fields. Do you know if this is possible?
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Possible to read the web.config during install?

Hello,

I'm afraid we don't have predefined support for this. As a workaround you can try to create your own custom action which will parse the related attribut value. Here are the steps to proceed:
- go to "Search" page and add an XML search which will search for your XML attribute (connectionString) and will store its value into an installer property (e.g. MY_PROP)
- create a custom action which will parse the above property and will save the required parameters values into another properties (e.g. SERVER_PROP, DATABASE_PROP, etc) which will be associated with your dialog controls (i.e. edit boxes)
- add the above custom action after "Wizard Dialogs Stage -> Searches" actions group

For example, you can create your custom action as a C++ custom action or as a C# custom action.

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”