Web config transform on microsoft.identityModel -

2019-03-23 19:56发布

问题:

I have got a Web.Release.config that is successfully transforming a connection string.

When I add a microsoft.identityModel section I get a warning saying

The 'http://schemas.microsoft.com/XML-Document-Transform' attribute is not declared

And the transform doesnt work on that section.

What am I missing to get the transform to work?

Complete Web.Release.config here

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

  <connectionStrings>    

    <add name="MYNAME"
         connectionString="metadata=res://*/Models.MYCOMPANY-Sales-Demo.csdl|res://*/Models.MYCOMPANY-Sales-Demo.ssdl|res://*/Models.MYCOMPANY-Sales-Demo.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=MYCOMPANYDemo;UID=MYCOMPANYDBUser;Password=********;multipleactiveresultsets=True;App=EntityFramework&quot;"         
         xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
  </connectionStrings>

  <system.web>
    <compilation xdt:Transform="RemoveAttributes(debug)" />
  </system.web>


  <microsoft.identityModel> 
    <service>
      <audienceUris>
        <add value="http://MYCOMPANY-sales-demo.cloudapp.net/" xdt:Transform="Replace"/>
      </audienceUris>
      <federatedAuthentication>
        <wsFederation realm="http://MYCOMPANY-sales-demo.cloudapp.net/" xdt:Transform="SetAttributes(realm)" />
      </federatedAuthentication>       
    </service>
  </microsoft.identityModel>

</configuration>

回答1:

I've run into this also but have gotten it to work. What I did was a "RemoveAll" and an "Insert" instead of a replace/match:

<audienceUris>
    <add xdt:Transform="RemoveAll" />
    <add value="http://example.com/" xdt:Transform="Insert" />
</audienceUris>

When I do it that way I get the desired transform and output config file.



回答2:

This appears to be working now with Visual Studio 2012 (v4.5.50709). I still get the 'attribute is not declared' warning in the editor, but the xdt:Transform="Replace" directive is working for me.