首页 > 解决方案 > util:XmlFile 开始 - 在 ElementPath 中不起作用

问题描述

我正在尝试使用 Wix 的 util:XmlFile 在我的服务配置文件中设置主机值。要选择节点,我想使用带有 start-with 功能的 XPath 来更改多个节点。

我在https://www.freeformatter.com/xpath-tester.html上尝试过 XPath 表达式,它工作正常。

     <util:XmlFile 
      Id="SomeId" 
      Action="setValue" 
      Permanent="yes"
      ElementPath="/configuration/system.serviceModel/services/service[\[]starts-with(@name,'Webservices') and ends-with(@name,'Service')[\]]/host/baseAddresses/add"
      Name="baseAddress" 
      File="[#Service_exe_config]"
      Value="[SERVICE_PROTOCOL]://[HOSTADDRESS]/Management/SomeService"
      SelectionLanguage="XPath" 
      Sequence="1" />

XML:

<configuration>
  <system.serviceModel>
    <services>
      <service name="MyCompany.Webservices.V123.Service">
        <host>
          <baseAddresses>
            <add baseAddress="https://localhost/Service"/>
          </baseAddresses>
        </host>        
      </service>
    </services>
  </system.serviceModel>
</configuration>

从安装程序中,我收到此错误:“错误 25532。找不到节点:”。如果它能正常工作,那就太好了。

标签: wix

解决方案


推荐阅读