Modify web.config in install shield 2008

HI,
In my deplyment project, i have 2 seperate component:
1. the web services
2. the web application.
During the installation process, we ask teh user to provide teh port number, and we create a new IIS site on this port.
However, we have also to modify the web.config in order to define the new location of the web services that ahs been deployed (Exampe http://localHost:81/xxxxxxx) where 81 is teh port number supplied by the user.
I have been looking into XML Changes, but could not input calculated value. it accepts only constants.
Do you have a method that can help?
zrodAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nhenny2009Commented:
This could easily be handled via a custom action.  Pass the info you need to the CA and have the CA update the web.config file.
0
zrodAuthor Commented:
Can you provide me with guideline:
1. Where in teh custom action we can add this procedure?
2. How to code this procedure
0
nhenny2009Commented:
1. I assume you are delivering the web.config as part of your package.  You would want to do the CA after "InstallFiles" to ensure the web.config has been dumped on the system.  
2.  Code a CA in C#, VB, VBScript, etc.  You could have the CA do a replace on text or use built in XML functions of the coding language to up the .config file.
Attached is some sample C# methods you could use if you go that route.


            public bool ReplaceValueElement(string filename, string elementName, string key, string value)
            {
                bool retval = false;
                System.Xml.XmlDocument thisDocument = new System.Xml.XmlDocument();
                thisDocument.Load(filename);
                System.Xml.XmlNodeList thisList = thisDocument.GetElementsByTagName(elementName);
 
                foreach (System.Xml.XmlNode thisNode in thisList)
                {
                    System.Xml.XmlAttributeCollection thisAttributeList = thisNode.Attributes;
                    foreach (System.Xml.XmlAttribute thisAttribute in thisAttributeList)
                    {
                        if (thisAttribute.Value == key)
                        {
                            System.Xml.XmlNode valueNode = thisNode.ChildNodes[0];
                            if (valueNode.NodeType.ToString() == "Comment")
                            {
                                valueNode = thisNode.ChildNodes[1];
                            }
                            valueNode.InnerText = value;
                        }
                    }
                }
 
                thisDocument.Save(filename);
                return retval;
            }
 
            public bool ReplaceValueAtrribute(string filename, string elementName, string key, string AttributeName, string value, string OptionalSearchCriteria, string OptionalValueMatch)
            {
                bool retval = false;
                System.Xml.XmlDocument thisDocument = new System.Xml.XmlDocument();
                thisDocument.Load(filename);
                System.Xml.XmlNodeList thisList = thisDocument.GetElementsByTagName(elementName);
 
                foreach (System.Xml.XmlNode thisNode in thisList)
                {
                    System.Xml.XmlAttributeCollection thisAttributeList = thisNode.Attributes;
                    foreach (System.Xml.XmlAttribute thisAttribute in thisAttributeList)
                    {
                        if (thisAttribute.Name == AttributeName)
                        {
                            if (OptionalSearchCriteria != "")
                            {
                                if (!thisAttribute.Value.Contains(OptionalSearchCriteria))
                                {
                                    continue;
                                }
                            }
                            if (OptionalValueMatch != string.Empty)
                            {
                                if (OptionalValueMatch!=thisAttribute.Value)
                                {
                                    continue;
                                }
                            }
                            thisAttribute.Value = value;
                            thisDocument.Save(filename);
                            return retval;
                        }
                    }
                }

Open in new window

0
nhenny2009Commented:
keep in mind the methods above have been tailored to my needs so they may need some slight modification for your specific needs.
0
nhenny2009Commented:
Here is another good article that may be of help if you want to use Install Script:

http://community.installshield.com/showthread.php?p=415226

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.