Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web.Debug.config not processing substitution

I have a web application in VS2010 with a web.config like this:

...
<configuration>
  <connectionStrings>
    <add name="ApplicationServices"
         connectionString="data source=MyProdDb;Initial Catalog=MyCat;User Id=MyUser;Password=MyPass;"
         providerName="System.Data.SqlClient" /> 
  </connectionStrings>
...

and a Web.Debug.config like this:

...
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    <connectionStrings>
        <add name="ApplicationServices"
          connectionString="data source=MyDevDb;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
          xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
    </connectionStrings>
...

The project is set to create a Debug build, and when I run it in the debugger, I get MyProdDb rather than MyDevDb

What am I missing?

like image 481
Eric J. Avatar asked Dec 27 '11 21:12

Eric J.


2 Answers

UPDATED INFORMATION

Arbitrary XML-based .config files can now be processed, and the processing can happen at build time rather than at deployment time

http://www.hanselman.com/blog/SlowCheetahWebconfigTransformationSyntaxNowGeneralizedForAnyXMLConfigurationFile.aspx

Brilliantly, the transforms can also be previewed directly in Visual Studio.

like image 120
Eric J. Avatar answered Sep 30 '22 15:09

Eric J.


As people have said the web.config versions only get applied at publish (MSDeploy) time. The normal way you would do things is to have your 'Debug' config in the actual web.config file and make changes to that for each of the deployment scenarios you have.

like image 23
Not loved Avatar answered Sep 30 '22 13:09

Not loved