您好我正在尝试使用以下更改配置文件中的值设置:
<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>
Run Code Online (Sandbox Code Playgroud)
此代码不会更改applicationHost.config文件中的值.我尝试添加action="create"但我在安装过程中遇到错误,无法打开XML文件.我究竟做错了什么?
我认为使用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>
Run Code Online (Sandbox Code Playgroud)
您必须在上面的代码片段中正确分配序列号。
您的 XmlConfig 元素中也缺少 Sequence 属性,因此您的代码可能存在问题。另一个问题是属性的定义ElementPath。添加@enable32BitAppOnWin64进去是错误的。该ElementPath属性定位您想要更改的元素,在您的情况下,该add元素具有name属性DefaultAppPool。在该元素中,您想要更改属性的值。您可以通过名称指定属性。为此,您必须将该name属性添加到您的XmlConfig元素中。结合Node属性设置到value属性定义就完成了。XmlConfig 元素的属性Action必须设置为create。XmlConfig 元素的属性VerifyPath用于确定是否应添加或修改节点。
XmlConfig 元素的正确版本应如下所示:
<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>
Run Code Online (Sandbox Code Playgroud)
如果您的安装程序告诉您无法打开 XML 文件,那么您必须检查该File属性的值是否正确。也许您需要将其更改为类似的内容"[INSTALLFOLDER]\config\applicationHost.config"或您将Id安装目录的属性设置为的任何内容。安装程序日志应向您提供无法打开哪个文件的信息。