Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set debug false for release mode

I have this web.config file with the compilation option set as below

Web.config

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

And here is what Visual Studio puts for release mode by default.

Web.Release.config

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">  <system.web>     <compilation xdt:Transform="RemoveAttributes(debug)" />  </system.web> </configuration> 

I am using this for MVC4 project. Based on this tutorial, I was expecting that minified versions of js and css would be served, when the application is run under Release Mode. But this doesn't seem to be working and non-minified versions of js and css are being served. On the other hand, if I explicitly set debug to false in web.config, then the min versions are served correctly.

It seems like compilation tag Transform issue when the application is run under Release Mode, but I don't understand what's wrong with the same in Web.Release.config.

In short, I am unable to get bundling and minification working, by running application under Release Mode.

like image 968
Jatin Avatar asked Feb 28 '14 04:02

Jatin


People also ask

Can you debug in release mode?

You can now debug your release build application. To find a problem, step through the code (or use Just-In-Time debugging) until you find where the failure occurs, and then determine the incorrect parameters or code.

How do I change debug to release in Visual Studio?

On the toolbar, choose either Debug or Release from the Solution Configurations list. From the Build menu, select Configuration Manager, then select Debug or Release.

Is release mode faster than debug?

Lots of your code could be completely removed or rewritten in Release mode. The resulting executable will most likely not match up with your written code. Because of this release mode will run faster than debug mode due to the optimizations.


1 Answers

Web.config transformations as they are defined in the Web.Release.config are only done when deploying/publishing the project for the relevant configuration.

Just changing the active configuration in Visual Studio to Release and running the application does not run the transformations. Therefore, the web.config remains unchanged. This behavior is reasonable by the way as a web application is run from the project directory that contains the original web.config. If Visual Studio were to transform the web.consign, your original web.config would be changed.

If you haven't created a deployment profile yet, you can publish your application to the file system to verify the behavior. Choose Release as the configuration to run the deployment for. The transformations should be executed as expected.

like image 97
Markus Avatar answered Sep 22 '22 13:09

Markus