Visual Studio Web.config Transforms

12/20/2014 5:05:37 PM

The following represents a Web.config transform. This will replace the configsource for connectionStrings, appSettings, and the customErrors sections of the web.config. It will also point the config source to a subdirectory. The double \\ is necessary for the configs to be read properly.

This transform will also change the compilation mode from debug="true" to debug="false" by removing the debug attribute.

*The content below would be placed in your Web.Release.config file.

<?xml version="1.0"?>

<!--Web.Release.Config -->

<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->

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

  <connectionStrings configSource=".\\Configs\\ConnectionStrings.prod.config" xdt:Transform="Replace" />
  <appSettings configSource=".\\Configs\\AppSettings.prod.config" xdt:Transform="Replace" />
  
  <system.web>

    <compilation xdt:Transform="RemoveAttributes(debug,batch)"></compilation>
    <customErrors configSource=".\\Configs\\CustomErrors.prod.config" xdt:Transform="Replace" />
    
  </system.web>
  
</configuration>