Multiple Config Transforms on Single Element
Hey everyone, so, I had a need to set some attributes and remove 2 of them in my web.config transform file. On my development system, I have my WCF services all pointing to my local fiddler, for debugging?
Anyways, I needed to remove the proxyAddress
attribute and also set the useDefaultWebProxy
, and securityMode
.
You can't put in 2 different transforms in the same element doing something like xdt:Transform="SetAttributes(useDefaultWebProxy),RemoveAttributes(proxyAddress)"
. The msbuild app pukes and says no. The fix, was to actually include the element twice. Here's an example.
<system.servicemodel>
<bindings>
<basichttpbinding>
<binding xdt:transform="SetAttributes" xdt:locator="Match(name)" usedefaultwebproxy="true" name="BasicHttpBinding_FrontendService">
<security xdt:transform="SetAttributes" mode="None">
</security></binding>
<binding xdt:transform="RemoveAttributes(proxyAddress)" xdt:locator="Match(name)" name="BasicHttpBinding_FrontendService">
</binding></basichttpbinding>
</bindings>
<client>
<endpoint xdt:transform="SetAttributes" xdt:locator="Match(contract)" contract="Website.Contracts.Service.IWebsiteServiceContract" address="http://devtest-int/Website.Services/WebsiteService.svc">
</endpoint>
</client>
</system.servicemodel>