2012-11-03 15 views
3

有沒有一種方法可以根據子屬性定位節點?或刪除匹配節點的父節點?刪除匹配定位器的父代

我需要運行一個web.config變換去除第二< dependentAssembly>在以下幾點:

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

尋找< assemblyIdentity>是很容易的,但我需要刪除父< dependentAssembly> (和< codeBase>)。如果有一個「xdt:Transform =」RemoveParent「,這會做的伎倆,但AFAIK沒有。

或者,如果有一個定位器,我可以使用< dependentAssembly>這將匹配兒童,那麼可能工作太

回答

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>