Reputation: 6514
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
Upvotes: 9
Views: 11339
Reputation: 17140
In Visual Studio 2013 if you only have a web.config file, you can right click it and choose "Add Config Transform". By default it contains the
<compilation xdt:Transform="RemoveAttributes(debug)" />
which removes the debug="true".
Upvotes: 2
Reputation: 57469
From my experience, Transformations do not happen when using the F5 or visual studio debugger. It only does transformations after you publish the website.
Upvotes: 6
Reputation: 6514
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".
Upvotes: 9