发布模式与调试=“假”

发布于 2024-09-10 09:20:00 字数 1046 浏览 5 评论 0原文

我试图找到一个明确的解释,说明在发布模式下编译与 debug="false" 相比对 .Net 3.5 Web 应用程序有何影响。到目前为止,看起来设置 debug="false" 具有相同的效果,并且在发布模式下编译已被贬值,但我找不到任何确凿的证据表明情况如此。

这个问题看起来很有希望,但似乎正在回答调试和发布版本之间的区别,而不是发布模式和 debug="true": 编译 debug="false" 和 Release 模式有什么区别?

但是它确实链接到这篇文章: http://odetocode.com/blogs/scott/archive/2005/11/15/debug-and-release-builds-in-asp-net-2-0.aspx

》这种新的编译模型使网站的配置管理器变得过时。出现在 Visual Studio 2005 网站“项目”中的唯一选项是“调试”配置 - 现在 web.config 文件没有任何意义。”

现在,这是我得到的最接近的答案,它似乎意味着发布模式已被贬值,转而使用 debug="false",但我在 MSDN 或任何其他来源上找不到对此的任何确认。

任何帮助将不胜感激。

更新

抱歉;澄清一下,这是我指的“Web 应用程序项目”。

稍微改一下我的问题,如果我在 web.config 中有以下设置:

发布和调试模式会产生什么影响(如果有)编译有吗?

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 this 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

我很OK 2024-09-17 09:20:00

TL;DR = 更重要的是编译debug=“true|false”。然而,在调试模式下编译对性能也有较小的影响。

调试和发布之间的区别(除了是否定义 DEBUG 常量之外)是“优化代码”标志,该标志在调试中禁用,在发布中启用。 (如果您查看项目设置的“构建”选项卡。)

“优化代码”标志告诉语言编译器在生成代码时进行一些优化(例如删除未使用的变量,并省略一些调试符号) DLL。与未设置该标志时相比,这是相对较小的性能改进(与 C#/VB 相比,C++ 中的影响可能更大),并且 DLL 内存使用量略有减少。

编译 debug="true" 标志告诉JIT 编译器应该连接此代码进行调试。这会降低多个维度的性能(加载时间、运行时间、内存和资源加载),但可以调试正在运行的代码。

如果您希望在生产中获得更详细的堆栈跟踪,那么您可以使用编译 debug="false" 来运行调试构建,而性能差异很小。但我会测试两者的性能,以确保您不会损失太多。

功劳属于这个答案,它链接到这篇博客文章,后来我发现了这个,其中包含所有这些信息。

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.

独自←快乐 2024-09-17 09:20:00

你必须小心你的用词选择。有“Web 应用程序”和“网站”项目。

“网站”项目没有“发布”配置。网站仅使用 web.config 编译部分中的调试设置。如果您打开“网站”,请注意“配置管理器”中唯一列出的配置是“调试”。您可以从项目的“MSBuild 选项”属性页或通过“发布网站”对话框控制编译。

配置“发布”和“调试”按“Web 应用程序”项目的预期工作。

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.

卷耳 2024-09-17 09:20:00

“发布”模式背后的想法“调试”模式是指,在调试模式下,编译包含调试符号,这对调试很有用,但对生产没有用,因为它会减慢进程。

但是,“发布”模式会删除这些调试符号,因此该过程运行良好,没有任何问题。

现在,微软已经在Web应用项目中实现了上述模型,而网站项目则略有不同。希望这有帮助。

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.

一花一树开 2024-09-17 09:20:00

这就是区别。如果您的 web.config 文件中有此内容:

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

并且您从 Visual Studio 的下拉列表中选择 Release (注意它们是冲突的),那么所有内容都会在调试模式或发布模式下编译吗?

Visual Studio 对编译 Web 应用程序一无所知。构建一个 Web 应用程序并检查 bin 文件夹,您会发现它是空的。这是因为 ASP.NET 编译了它。 ASP.NET 将使用配置文件中的 compilation debug 标志来确定如何编译 .cs 文件、构建表单和用户控件等。它还将使用此标志标志来决定是否应该执行捆绑和缩小。

总之,您可以使用 web.config 中编译部分的调试属性来控制调试和发布版本 - 除非您使用发布命令或网站部署工具预编译网站。 WSD 将允许您选择“调试”或“发布”版本、预编译站点并适当修改 web.config。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文