设置值XmlConfig

时间:2013-08-28 08:13:00

标签: wix

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

    <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文件。我做错了什么?

1 个答案:

答案 0 :(得分:4)

我认为使用XmlFile元素修改属性值更方便:

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

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

您的XmlConfig元素中也缺少Sequence属性,因此可能是您的代码存在问题。另一个问题是ElementPath属性的定义。添加@enable32BitAppOnWin64是错误的。 ElementPath属性定位您要更改的元素,在您的情况下,add元素的name属性为DefaultAppPool。在该元素中,您想要更改属性的值。您可以通过名称指定属性。为此,您必须将name属性添加到XmlConfig元素中。结合设置为Node的{​​{1}}属性,属性定义已完成。必须将XmlConfig元素的value属性设置为Action。 XmlConfig元素的create属性用于确定是否应添加或修改节点。

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

VerifyPath

如果安装程序告诉您无法打开XML文件,则必须检查<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> 属性的值是否正确。也许您需要将其更改为File或您将安装目录的"[INSTALLFOLDER]\config\applicationHost.config"属性设置为的任何内容。安装程序日志应该为您提供无法打开文件的信息。

相关问题