Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC Web.Debug.Config Question Concerning Debug Mode

This is probably a quick question. I'm very new to solution configurations and web.config xml file transformations. I wanted to add a transformation to set the debug attribute for the compilation element of an Asp.Net Mvc website to true:

Web.Debug.config:

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

Web.config:

<compilation targetFramework="4.0">
  <assemblies>
         ...
  </assemblies>
</compilation>

but when I press F5, a window pops up in Visual Studio saying "The page cannot be run in debug mode because debugging is not enabled in the web.config file." It then gives me the option to alter the Web.config file. But I thought the point of the Web.Debug.config file was to allow this to get set automatically... Can I get Visual Studio to use the transformed Web.config file after pressing F5?

Many thanks in advance!

Andrew

like image 622
Andrew Avatar asked May 15 '11 20:05

Andrew


1 Answers

Okay, I've decided to use the following setup instead:

Web.config:

<configuration>
    ...
  <system.web>    
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
          ...
      </assemblies>
    </compilation>
  </system.web>
    ...
</configuration>

Web.Release.config:

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

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

</configuration>

This should cause the compilation debug attribute to get overwritten with "false" when the build deployment configuration is set to "release".

like image 89
Andrew Avatar answered Oct 21 '22 03:10

Andrew