Web config transform on microsoft.identityModel - 'http://schemas.microsoft.com/XML-Document-Transform' attribute is not declared

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 16:04:57

问题


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.



来源:https://stackoverflow.com/questions/8513488/web-config-transform-on-microsoft-identitymodel-http-schemas-microsoft-com

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!