【问题标题】:Remove parent of matched locator删除匹配定位器的父级
【发布时间】:2012-10-23 21:30:34
【问题描述】:

有没有办法根据子属性定位节点?还是删除匹配节点的父节点?

我需要运行 web.config 转换以删除以下第二个

<runtime>
 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <!-- Don't want to delete this one -->
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
    <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
  </dependentAssembly>
  <!-- This is the one I want to delete -->
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.VisualStudio.Enterprise.AspNetHelper" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
    <codeBase version="11.0.0.0" href="file:///C:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio%2011.0/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.Enterprise.AspNetHelper.DLL"/>
  </dependentAssembly>
 </assemblyBinding>
</runtime>

找到 很容易,但我需要删除父 (和 )。如果有一个 "xdt:Transform="RemoveParent" 这可以解决问题,但 AFAIK 没有。

或者,如果我可以在 上使用一个定位器来匹配孩子,那么它也可以工作。

【问题讨论】:

    标签: web-config-transform


    【解决方案1】:

    找到答案over here

     <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly xdt:Transform="RemoveAll"
                         xdt:Locator="Condition(starts-with(./_defaultNamespace:assemblyIdentity/@name,'Microsoft.VisualStudio.Enterprise.AspNetHelper'))">
           </dependentAssembly>
        </assemblyBinding>
     </runtime>
    

    【讨论】:

      【解决方案2】:

      你可以使用这个解决方案:Clearing out xdt element if it has no children

      2 个步骤: - 首先移除孩子 - 其次删除空的 assemblyBinding 元素。

      【讨论】:

        猜你喜欢
        • 2021-12-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-03-22
        相关资源
        最近更新 更多