设置值 XmlConfig [英] Setting a value XmlConfig

查看:20
本文介绍了设置值 XmlConfig的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下内容更改配置文件中的值设置:

Hi I am trying to change a value setting in a config file using the following:

    <Component Id="Enable32BitAppPoolComponent" Guid="*" Directory="INSTALLLOCATION">
        <CreateFolder/>
        <util:XmlConfig Id="Enable32BitAppPool" Node="value"
                      ElementPath="//configuration/system.applicationHost/applicationPools/add[\[]@name='DefaultAppPool'[\]]/@enable32BitAppOnWin64"
                      File="[inetsrv]\config\applicationHost.config"
                      Value="true" On="install"/>
    </Component>

此代码不会更改 applicationHost.config 文件中的值.我尝试添加 action="create" 但我在安装过程中遇到了无法打开 XML 文件的错误.我做错了什么?

This code does not change the value in the applicationHost.config file. I tried adding the action="create" but I then got the error during the setup that it could not open the XML file. What am I doing wrong?

推荐答案

我觉得用XmlFile元素修改属性值更方便:

I think it's more convenient to use XmlFile elements to modify attribute values:

<Component Id="Enable32BitAppPoolComponent" Guid="*" Directory="INSTALLLOCATION">
<CreateFolder/>
<util:XmlFile Id="Enable32BitAppPool" 
    Action="setValue"
    Name="enable32BitAppOnWin64" 
    ElementPath="//configuration/system.applicationHost/applicationPools/add[\[]@name='DefaultAppPool'[\]]" 
    File="[inetsrv]\config\applicationHost.config" 
    PreserveModifiedDate="yes"
    SelectionLanguage="XPath" 
    Sequence="INSERTCORRECTSEQUENCENUMBERHERE"
    Value="true" />
</Component>

您必须在上面的代码片段中正确分配序列号.

You have to correctly assign the Sequence number in the snippet above.

您的 XmlConfig 元素中也缺少 Sequence 属性,因此这可能是您的代码有问题.另一个问题是ElementPath 属性的定义.添加 @enable32BitAppOnWin64 是错误的.ElementPath 属性定位您要更改的元素,在您的情况下是 add 元素,它具有 DefaultAppPoolname 属性代码>.在该元素中,您要更改属性的值.您可以按名称指定属性.为此,您必须将 name 属性添加到您的 XmlConfig 元素.结合设置为 valueNode 属性,属性定义就完成了.XmlConfig 元素的 Action 属性必须设置为 create.XmlConfig 元素的 VerifyPath 属性用于确定是否应添加或修改节点.

The Sequence attribute is also missing in your XmlConfig element, so that might be a problem with your code. Another problem is the definition of the ElementPath attribute. Adding @enable32BitAppOnWin64 to it is wrong. The ElementPath attribute locates the element you want to change, in your case the add element which has the name attribute of DefaultAppPool. In that element you want to change the value of an attribute. You specify the attribute by its name. For that purpose you have to add the name attribute to your XmlConfig element. In combination with the Node attribute set to value the attribute definition is complete. The Action attribute of the XmlConfig element has to be set to create. The VerifyPath attribute of the XmlConfig element is used to determine if the Node shall be added or modified.

您的 XmlConfig 元素的正确版本应如下所示:

The correct version of your XmlConfig element should look like this:

<Component Id="Enable32BitAppPoolComponent" Guid="*" Directory="INSTALLLOCATION">
    <CreateFolder/>
    <util:XmlConfig
    Id="Enable32BitAppPool"
    Action="create" 
    Node="value"
    ElementPath="//configuration/system.applicationHost/applicationPools/add[\[]@name='DefaultAppPool'[\]]"
    File="[inetsrv]\config\applicationHost.config"
    Name="enable32BitAppOnWin64"
    Value="true"
    On="install"/>
</Component>

如果您的安装程序告诉您它无法打开 XML 文件,那么您必须检查 File 属性的值是否正确.也许您需要将其更改为类似 "[INSTALLFOLDER]\config\applicationHost.config" 或您将安装目录的 Id 属性设置为的任何内容.安装程序日志应为您提供无法打开哪个文件的信息.

If your installer tells you it cannot open the XML File, then you have to check if the File attribute's value is correct. Maybe you need to change it to something like "[INSTALLFOLDER]\config\applicationHost.config" or whatever you set the Id attribute of your installation directory to. The installer log should provide you with the information which file could not be opened.

这篇关于设置值 XmlConfig的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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