InstallShield XML文件更改-安装时更改节点属性 [英] InstallShield XML File Changes - Change node attribute on install

查看:78
本文介绍了InstallShield XML文件更改-安装时更改节点属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用InstallShield 2012构建Web服务安装,并且需要根据用户输入修改应用程序的Web.config文件.我已经在DestinationFolder对话框之后引入了PromptServerAndDatabase对话框.我还已经在InstallShield的XML File Changes视图中设置了Web.config文件.这是我的基本web.config文件结构:

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.

这是XML文件更改视图中InstallShield中的结构:

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

此外,这是高级"选项卡,实际上对于所有三个节点而言都是相同的.与数据库名称关联的两个节点使用相同的属性,而服务器名称的节点使用属性[SERVER_NAME](未显示):

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):

运行安装程序后,将成功更新Web.config文件.DatabaseName和ServerName节点的值已更新.但是,数据库名称"节点中值"属性的值不是,尽管它应反映与节点的实际值相同的文本.完成这一步骤后,我需要将其复制到ServerName节点,但为简单起见,我将其省略.

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

也许答案就在那里,我只是想念它,IDK.

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

感谢您提供的任何帮助.

Thanks for any help offered on this.

推荐答案

好,所以我的问题是我对常规"选项卡和添加的属性有基本的误解.常规"选项卡上的属性实际上是XML节点的属性,该表中每个条目的value列是该属性将被设置为的值.因此,通过将该值更改为我要更改的属性,它解决了我的问题.我按原样保留高级"选项卡,因为那里的选项正确地更改了元素内容的值.最后,我更改了XPath查询以删除value属性,因为正在安装的web.config文件将来可能会更改此值.由于在appSettings节点中只有一个add节点,其键值为DatabaseName或ServerName,因此只需要XPath搜索key =".

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.

这是视觉效果:

这篇关于InstallShield XML文件更改-安装时更改节点属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆