开发者

Release Mode vs Debug = "false"

开发者 https://www.devze.com 2023-01-07 22:52 出处:网络
I\'m trying to find a definite explanation of what effect compiling in release mode has on a .Net 3.5 web application versus debug=\"false\". So far it looks like setting debug=\"false\" has the same

I'm trying to find a definite explanation of what effect compiling in release mode has on a .Net 3.5 web application versus debug="false". So far it looks like setting debug="false" has the same effect and compiling in release mode has been depreciated but I can't find any firm evidence this is the case.

This question looked promising but seems to be answering what's the difference between debug and release builds rather than release mode and debug="true": What's the difference between compilation debug="false" and Release mode?

However it does link to this article: http://odetocode.com/blogs/scott/archive/2005/11/15/debug-and-release-builds-in-asp-net-2-0.aspx

"This new compilation model makes the Configuration Manager for a web site obsolete. The only option appearing in a Visual Studio 2005 web site “project” is a Debug configuration. Don’t fret – it means nothing. The web.config file now rules the school."

Now that is the closest I've had to an answer and it does seem to imply that release mode has been depreciated in favor of debug="false" but I can't find any confirmation of thi开发者_如何学编程s on MSDN or any other source.

Any help would be greatly appreciated.

Update

Sorry; to clarify this is a "Web Application Project" I am referring to.

To rephrase my question slightly, if I have the following setting in web.config:

<compilation defaultLanguage="c#" debug="false">

What effect (if any) does release and debug mode compile have?


TL;DR = The more important thing is compilation debug="true|false". However, compiling in Debug has a minor effect on performance too.

The difference between Debug and Release (aside from defining the DEBUG constant or not) is the "Optimize code" flag, which is disabled in Debug and enabled in Release. (If you look at the project settings, Build tab.)

The "Optimize code" flag tells the language compiler to do some optimizations (like removing unused variables, and leaving out some debugging symbols) when producing the DLL. This is a relatively minor performance improvement (maybe a larger impact in C++ vs C#/VB) and a slight reduction in DLL memory usage, compared to when the flag is not set.

The compilation debug="true" flag tells the JIT compiler that this code should be hooked up for debugging. This reduces performance in several dimensions (load time, run time, memory, and resource loading) but enables debugging of running code.

If you want more detailed stack traces in production, then you can probably run a Debug build with compilation debug="false" with little performance difference. But I would test the performance for both to make sure you're not losing too much.

Credit belongs to this answer which links to this blog entry, and I later found this one, which contains all this info.


You have to be careful of your word choice. There are "Web Application" and "Web Site" projects.

There is no "Release" configuration for "Web Site" projects. Web sites only use the debug setting in the compilation section of web.config. If you open a "Web Site", notice the only listed configuration in the "Configuration Manager" is "Debug". You can control compilation from the project's "MSBuild Options" property page or through the "Publish Web Site" dialog.

The configurations "Release" and "Debug" work as expected for "Web Application" projects.


The idea behind 'Release' mode & 'Debug' mode is that, in debug mode, the compilation contains debug symbols which is useful for debugging but not for production, as it slows down the process.

However, 'Release' mode removes these debug symbols therefore the process runs fine without any issue.

Now, Microsoft has implemented the above model in web application projects while website project is slightly different. Hope this helps.


Here is the difference. If you have this in your web.config file:

<system.web>
    <compilation debug="true" .../>

And you select Release from the dropdown in Visual Studio (note they are conflicting), would everything be compiled in debug mode or release mode?

Visual Studio knows nothing about compiling a web application. Build a web application and check the bin folder and you will notice it is empty. That is because ASP.NET compiles it. ASP.NET will use the compilation debug flag from the config file to figure out how to compile the .cs files, build forms and user controls etc. It will also use this flag to decide if it should perform bundling and minification.

This article sums it up pretty nicely:

In conclusion, you control debug and release builds using the debug attribute of the compilation section in web.config – unless you are precompiling the website with the Publish command or the Web Site Deployment tool. The WSD will let you select Debug or Release builds, precompiles the site, and modifies web.config appropriately.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号