3

I have the following XML in my web config and in release mode I need to remove dependentAssembly section depending on the name attribute of its child : assemblyIdentity. I tried the answer here:xdt transform locator that matches subnode content but no luck. My web.config is something like this:

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
 <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.Resource" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <codeBase version="10.0.0.0" href="file:///c:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio%2010.0/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.QualityTools.HostAdapters.ASPNETAdapter.DLL" />
      </dependentAssembly>
  </assemblyBinding>
  </runtime>
</configuration>

I have tried the following in my web.release.config to select the second dependentAssembly element for deletion based on the child element but no success.

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" >
          <dependentAssembly>
<!-- Attempt 1 -->
            <assemblyIdentity  xdt:Transform="RemoveAll"
             xdt:Locator="Condition(@name='Microsoft.VisualStudio.QualityTools.Resource')"/>
          </dependentAssembly>
        </assemblyBinding>
<!-- Attempt 2 -->
 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly xdt:Transform="Remove"
       xdt:Locator="Condition(assemblyIdentity/@name='Microsoft.VisualStudio.QualityTools.Resource')">
        </dependentAssembly>
     </assemblyBinding>
      </runtime>
Community
  • 1
  • 1
  • https://webconfigtransformationtester.apphb.com/ is helpful for getting transforms down. Also your dependentAssembly names do not match the provided config, and what is in the locator. – BenM Jan 30 '15 at 21:20
  • That was my mistake on the assembly names, I edited the post. Thank you. The sitee you provided is helpful but i still cant figure it out – Firat Bakioglu Feb 02 '15 at 15:18

1 Answers1

5

This code works for me.

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly xdt:Transform="Replace" xdt:Locator="Condition(./_defaultNamespace:assemblyIdentity/@name='System.Web.Mvc')">
      <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
      <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
    </dependentAssembly>      
  </assemblyBinding>
</runtime>

All credit to @Thommy's stackoverflow answer to this post.

Community
  • 1
  • 1
Kevin Obee
  • 1,489
  • 1
  • 12
  • 22