Question

I am building a web service installation using InstallShield 2012, and I need to modify the Web.config file of my app based on user input. I have introduced the PromptServerAndDatabase dialog just after the DestinationFolder dialog. I have also set up the Web.config file in the XML File Changes view in InstallShield. Here is my basic web.config file structure:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <configSections>
        ...
    </configSections>
    <appSettings>
        <add key="DatabaseServer" value="sql08r2">sql08r2</add>
        <add key="DatabaseName" value="UserDatabaseName">UserDatabaseName</add>
    </appSettings>
    ...
</configuration>

At this time I can successfully change the literal value of a node, but I cannot change an attribute of a node.

Here's the structure within InstallShield in the XML File Changes view:

XML Structure

Also, here's the Advanced tab which is virtually identical for all three nodes. Both nodes associated with Database Name use the same property, while the node for Server Name uses the property [SERVER_NAME] (not shown): Advanced Tab

After running the installer the Web.config file is successfully updated. The values of the DatabaseName and ServerName nodes are updated. However, the value for the "value" attribute in the DatabaseName node is not, although it should reflect the same text as the node's actual value. Once I perfect this I will need to duplicate it for the ServerName node, but I left that out for simplicity.

I have done some additional research on this and I found this site which was very helpful overall, but didn't resolve this issue for me:

http://helpnet.installshield.com/installshield16helplib/XML-XPath.htm

Maybe the answer is there and I am just missing it, IDK.

Thanks for any help offered on this.

Was it helpful?

Solution

OK so my problem was that I had a basic misunderstanding of the General tab and the attributes being added there. The attributes on the General tab are literally the attributes of the XML node, and the value column of each entry in that table is the value that the attribute will be set to. So by changing that value to the property I was changing, it solved my problem. I left the Advanced tab as-is because my options there were correctly changing the value of the element's content. Finally, I changed the XPath query to remove the value attribute because there is a chance that the web.config file being installed will change this value in the future. Since there is only one add node with a key value of DatabaseName or ServerName within the appSettings node, the XPath search for key="" was all I needed.

Here's a visual: enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top