Wix XmlConfig 验证路径行为
Posted
技术标签:
【中文标题】Wix XmlConfig 验证路径行为【英文标题】:Wix XmlConfig VerifyPath behavior 【发布时间】:2014-02-06 17:33:38 【问题描述】:在我的 wix 安装程序中,我有一个组件,它只是将 wcf 绑定添加到 web.config。现在,当安装基础产品并启用不同的 wcf 服务时,我的安装程序不会将其绑定信息添加到 web.config。
我很确定这是因为 web.config 中已经有一个用于其他服务的 wsHttpBinding 元素。
所以我的问题是我可以在我的 VerifyPath 中使用任何路径吗?除了检查该根元素是否存在之外,我还可以检查其下的嵌套元素是否具有我要查找的名称吗?
以下是我的 XmlConfig 语句供参考:
<util:XmlConfig Id="EndPointIP_wsHttpBinding" Action="create" On="install" Node="element" Name="wsHttpBinding" ElementPath="/configuration/system.serviceModel/bindings" File="[Web]web.config" VerifyPath="/configuration/system.serviceModel/bindings/wsHttpBinding" Sequence="1" />
<util:XmlConfig Id="EndPointIP_wsHttpBinding_binding" Action="create" On="install" Node="element" Name="binding" ElementPath="/configuration/system.serviceModel/bindings/wsHttpBinding" File="[Web]web.config" VerifyPath="/configuration/system.serviceModel/bindings/wsHttpBinding/binding" Sequence="2" />
<util:XmlConfig Id="EndPointIP_wsHttpBinding_binding_name" ElementId="EndPointIP_wsHttpBinding_binding" Name="name" Value="wsHTTPBindingConfig" File="[Web]web.config" Sequence="3" />
<util:XmlConfig Id="EndPointIP_wsHttpBinding_binding_closeTimeout" ElementId="EndPointIP_wsHttpBinding_binding" Name="closeTimeout" Value="00:10:00" File="[Web]web.config" Sequence="4" />
<util:XmlConfig Id="EndPointIP_wsHttpBinding_binding_openTimeout" ElementId="EndPointIP_wsHttpBinding_binding" Name="openTimeout" Value="00:10:00" File="[Web]web.config" Sequence="5" />
<util:XmlConfig Id="EndPointIP_wsHttpBinding_binding_receiveTimeout" ElementId="EndPointIP_wsHttpBinding_binding" Name="receiveTimeout" Value="00:10:00" File="[Web]web.config" Sequence="6" />
<util:XmlConfig Id="EndPointIP_wsHttpBinding_binding_sendTimeout" ElementId="EndPointIP_wsHttpBinding_binding" Name="sendTimeout" Value="00:10:00" File="[Web]web.config" Sequence="7" />
<util:XmlConfig Id="EndPointIP_wsHttpBinding_binding_maxBufferPoolSize" ElementId="EndPointIP_wsHttpBinding_binding" Name="maxBufferPoolSize" Value="524288" File="[Web]web.config" Sequence="8" />
<util:XmlConfig Id="EndPointIP_wsHttpBinding_binding_maxReceivedMessageSize" ElementId="EndPointIP_wsHttpBinding_binding" Name="maxReceivedMessageSize" Value="2147483647" File="[Web]web.config" Sequence="9" />
<util:XmlConfig Id="EndPointIP_wsHttpBinding_binding_readerQuotas" Action="create" On="install" Node="element" Name="readerQuotas" ElementPath="/configuration/system.serviceModel/bindings/wsHttpBinding/binding" File="[Web]web.config" VerifyPath="/configuration/system.serviceModel/bindings/wsHttpBinding/binding/readerQuotas" Sequence="10" />
<util:XmlConfig Id="EndPointIP_wsHttpBinding_binding_readerQuotas_maxDepth" ElementId="EndPointIP_wsHttpBinding_binding_readerQuotas" Name="maxDepth" Value="32" File="[Web]web.config" Sequence="11" />
<util:XmlConfig Id="EndPointIP_wsHttpBinding_binding_readerQuotas_maxStringContentLength" ElementId="EndPointIP_wsHttpBinding_binding_readerQuotas" Name="maxStringContentLength" Value="2147483647" File="[Web]web.config" Sequence="12" />
<util:XmlConfig Id="EndPointIP_wsHttpBinding_binding_readerQuotas_maxArrayLength" ElementId="EndPointIP_wsHttpBinding_binding_readerQuotas" Name="maxArrayLength" Value="2147483647" File="[Web]web.config" Sequence="13" />
<util:XmlConfig Id="EndPointIP_wsHttpBinding_binding_readerQuotas_maxBytesPerRead" ElementId="EndPointIP_wsHttpBinding_binding_readerQuotas" Name="maxBytesPerRead" Value="4096" File="[Web]web.config" Sequence="14" />
<util:XmlConfig Id="EndPointIP_wsHttpBinding_binding_readerQuotas_maxNameTableCharCount" ElementId="EndPointIP_wsHttpBinding_binding_readerQuotas" Name="maxNameTableCharCount" Value="16384" File="[Web]web.config" Sequence="15" />
<util:XmlConfig Id="EndPointIP_wsHttpBinding_binding_security" Action="create" On="install" Node="element" Name="security" ElementPath="/configuration/system.serviceModel/bindings/wsHttpBinding/binding" File="[Web]web.config" VerifyPath="/configuration/system.serviceModel/bindings/wsHttpBinding/binding/security" Sequence="16" />
<util:XmlConfig Id="EndPointIP_wsHttpBinding_binding_security_mode" ElementId="EndPointIP_wsHttpBinding_binding_security" Name="mode" Value="None" File="[Web]web.config" Sequence="17" />
<util:XmlConfig Id="EndPointIP_wsHttpBinding_binding_security_transport" Action="create" On="install" Node="element" Name="transport" ElementPath="/configuration/system.serviceModel/bindings/wsHttpBinding/binding/security" File="[Web]web.config" VerifyPath="/configuration/system.serviceModel/bindings/wsHttpBinding/binding/security/transport" Sequence="18" />
<util:XmlConfig Id="EndPointIP_transport_clientCredentialType" ElementId="EndPointIP_wsHttpBinding_binding_security_transport" Name="clientCredentialType" Value="None" File="[Web]web.config" Sequence="19" />
<util:XmlConfig Id="EndPointIP_wsHttpBinding_binding_security_message" Action="create" On="install" Node="element" Name="message" ElementPath="/configuration/system.serviceModel/bindings/wsHttpBinding/binding/security" File="[Web]web.config" VerifyPath="/configuration/system.serviceModel/bindings/wsHttpBinding/binding/security/message" Sequence="20" />
<util:XmlConfig Id="EndPointIP_security_message_establishSecurityContext" ElementId="EndPointIP_wsHttpBinding_binding_security_message" Name="establishSecurityContext" Value="false" File="[Web]web.config" Sequence="21" />
<util:XmlConfig Id="EndPointIP_endpoint" Action="create" On="install" Node="element" Name="endpoint" ElementPath="/configuration/system.serviceModel/client" File="[Web]web.config" VerifyPath="/configuration/system.serviceModel/client/endpoint" Sequence="22" />
<util:XmlConfig Id="EndPointIP_endpoint_address" ElementId="EndPointIP_endpoint" Name="address" Value="[CLAIMSURL]" File="[Web]web.config" Sequence="23" />
<util:XmlConfig Id="EndPointIP_endpoint_binding" ElementId="EndPointIP_endpoint" Name="binding" Value="wsHttpBinding" File="[Web]web.config" Sequence="24" />
<util:XmlConfig Id="EndPointIP_endpoint_bindingConfiguration" ElementId="EndPointIP_endpoint" Name="bindingConfiguration" Value="wsHTTPBindingConfig" File="[Web]web.config" Sequence="25" />
<util:XmlConfig Id="EndPointIP_endpoint_contract" ElementId="EndPointIP_endpoint" Name="contract" Value="LossHistoryService" File="[Web]web.config" Sequence="26" />
【问题讨论】:
【参考方案1】:VerifyPath 基本上使用 XPATH 查询,因此如果您编写正确的查询来选择属性,您应该能够比较或检查它
要在 web.config 中选择一个条目“service1binding”,我们将使用以下 XPATH 查询
<wsHttpBinding>
<binding name="service1binding">
XPATH 查询
"/configuration/system.serviceModel/bindings/wsHttpBinding/binding[@name='service1binding']"
上述 XPATH 查询未针对 WIX 进行格式化,您无法按原样使用它
请注意,VERIFYPATH 是一个格式化的字段,因此必须对 XPath 中的方括号进行转义。此外,XPath 允许使用反斜杠来转义字符,因此如果您打算包含文字反斜杠,则还必须通过在此属性中将它们加倍来转义它们。字符串先由 MSI 格式化,结果作为 XPath 消费。
【讨论】:
谢谢,这是我想知道的。以上是关于Wix XmlConfig 验证路径行为的主要内容,如果未能解决你的问题,请参考以下文章