简体   繁体   English

InstallShield XML文件更改 - 在安装时更改节点属性

[英]InstallShield XML File Changes - Change node attribute on install

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. 我正在使用InstallShield 2012构建Web服务安装,我需要根据用户输入修改我的应用程序的Web.config文件。 I have introduced the PromptServerAndDatabase dialog just after the DestinationFolder dialog. 我在DestinationFolder对话框之后引入了PromptServerAndDatabase对话框。 I have also set up the Web.config file in the XML File Changes view in InstallShield. 我还在InstallShield的XML File Changes视图中设置了Web.config文件。 Here is my basic web.config file structure: 这是我的基本web.config文件结构:

<?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文件更改视图中InstallShield中的结构:

XML结构

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): 与Database Name关联的两个节点使用相同的属性,而Server Name的节点使用属性[SERVER_NAME](未显示): 高级选项卡

After running the installer the Web.config file is successfully updated. 运行安装程序后,Web.config文件已成功更新。 The values of the DatabaseName and ServerName nodes are updated. DatabaseName和ServerName节点的值已更新。 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. 但是,DatabaseName节点中“value”属性的值不是,尽管它应该反映与节点实际值相同的文本。 Once I perfect this I will need to duplicate it for the ServerName node, but I left that out for simplicity. 一旦我完善了这个,我将需要为ServerName节点复制它,但为了简单起见,我把它留了下来。

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 http://helpnet.installshield.com/installshield16helplib/XML-XPath.htm

Maybe the answer is there and I am just missing it, IDK. 也许答案就在那里,我只是想念它,IDK。

Thanks for any help offered on this. 感谢您提供的任何帮助。

OK so my problem was that I had a basic misunderstanding of the General tab and the attributes being added there. 好吧我的问题是我对General选项卡和添加的属性有一个基本的误解。 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. “常规”选项卡上的属性实际上是XML节点的属性,该表中每个条目的值列是该属性将设置的值。 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. 最后,我更改了XPath查询以删除value属性,因为正在安装的web.config文件将来可能会更改此值。 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. 由于appSettings节点中只有一个添加节点的键值为DatabaseName或ServerName,因此我只需要搜索key =“”的XPath。

Here's a visual: 这是一个视觉: 在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM