Xavier W.
Xavier W.

Reputation: 1360

Add web.release.config value at compilation

I need to add this block to my binding in my web.config when there is a release compilation :

<security mode="Transport">
  <transport clientCredentialType="None"/>
</security>

Here is the snippet of my web.config :

<bindings>
  <basicHttpBinding>
    <binding name="BasicBinding" closeTimeout="24.20:31:23.6470000" openTimeout="24.20:31:23.6470000" receiveTimeout="24.20:31:23.6470000" sendTimeout="24.20:31:23.6470000" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" transferMode="Buffered" useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
  </basicHttpBinding>
</bindings>

And here is my transformation method web.release.config following this documentation :

<bindings>
<basicHttpBinding>
  <binding>
    <security mode="Transport" xdt:Transform="InsertAfter(/configuration/system.serviceModel/bindings/basicHttpBinding/binding)">
      <transport clientCredentialType="None"/>
    </security>
  </binding>
</basicHttpBinding>
</bindings>

I face the following erreur on compilation on VSTS :

[error]Sources\Foo.Interface\Web.Release.config(16,6): Error : No element in the source document matches '/configuration/bindings/basicHttpBinding'

Of course I tried with other similar values but facing all time the same issue.

Upvotes: 0

Views: 45

Answers (1)

Ackelry Xu
Ackelry Xu

Reputation: 776

Not clear about the error. But if you want to insert security node into your web.config's binding node, you could write the following code in your web.release.config using xdt:Transform="Insert"

  <system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="BasicBinding" >
      <security mode="Transport"  xdt:Transform="Insert" >
        <transport clientCredentialType="None"/>
      </security>

    </binding>
  </basicHttpBinding>
</bindings>

Upvotes: 1

Related Questions