Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove parent of matched locator

Is there a way to locate a node based on child properties? or to delete the parent of the matched node?

I need to run a web.config transform to remove the 2nd <dependentAssembly> in the following:

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

Finding the <assemblyIdentity> is easy enough, but I need to delete the parent <dependentAssembly> (and <codeBase>). If there was a "xdt:Transform="RemoveParent" this would do the trick, but AFAIK there isn't.

Alternatively if there was a Locator I could use on the <dependentAssembly> which would match children, then that could work too.

like image 211
Ilan Avatar asked Oct 06 '22 02:10

Ilan


1 Answers

Found the answer 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>
like image 100
James White Avatar answered Oct 10 '22 02:10

James White