app.config transformations not applying

2019-08-29 02:00发布

问题:

I'm having an issue with app.config transformations using SlowCheeta not applying on publish. It always uses dbTable, not dbTableLive.

app.config

  <connectionStrings>
    <add name="db2" connectionString="metadata=res://*/db2.csdl|res://*/db2.ssdl|res://*/db2.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=server;initial catalog=db2Table;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    <add name="db"
         connectionString="metadata=res://*/db.csdl|res://*/db.ssdl|res://*/db.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=server;initial catalog=dbTable;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework&quot;" 
         providerName="System.Data.EntityClient"/>
  </connectionStrings>

app.release.config

<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations 
     see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <connectionStrings >
    <add name="db"
         connectionString="metadata=res://*/db.csdl|res://*/db.ssdl|res://*/db.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=server;initial catalog=dbTableLive;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework&quot;"
         providerName="System.Data.EntityClient"
         xdt:Transform="Replace"
         xdt:Locator="Match(name)"/>
  </connectionStrings>
</configuration>

回答1:

The issue was that I hadn't changed the configuration to "Release" prior to publishing the project.