151

Possible Duplicate:
Debug vs. release in .NET
Debug/Release difference

What is the difference between Release and Debug modes in Visual Studio while building a project?

1

3 Answers 3

143

Debug and Release are just labels for different solution configurations. You can add others if you want. A project I once worked on had one called "Debug Internal" which was used to turn on the in-house editing features of the application. You can see this if you go to Configuration Manager... (it's on the Build menu). You can find more information on MSDN Library under Configuration Manager Dialog Box.

Each solution configuration then consists of a bunch of project configurations. Again, these are just labels, this time for a collection of settings for your project. For example, our C++ library projects have project configurations called "Debug", "Debug_Unicode", "Debug_MT", etc.

The available settings depend on what type of project you're building. For a .NET project, it's a fairly small set: #defines and a few other things. For a C++ project, you get a much bigger variety of things to tweak.

In general, though, you'll use "Debug" when you want your project to be built with the optimiser turned off, and when you want full debugging/symbol information included in your build (in the .PDB file, usually). You'll use "Release" when you want the optimiser turned on, and when you don't want full debugging information included.

6
  • The project configurations can be edited by right clicking on a project in the SolutionExplorer and choosing Properties from the context menu. In order to edit the debugging settings for the project configuration "Release", select the tab "Debug" on the left side and select "Release" with the combo box called "Configuration". =>Using the label "Debug" for a solution configuration or project configuration might be misleading since the "Release" configuration can also be debugged.
    – Stefan
    Commented Jul 11, 2017 at 8:51
  • Also see following question on how to enable/disable compile optimization. stackoverflow.com/questions/1199204/… (In VB.NET it can be found on the Compile tab => Advanced Compile Options...)
    – Stefan
    Commented Jul 11, 2017 at 9:03
  • If you want to disable the creation of debugging information for release mode you can do so by setting the option "Generate debug info" to None. Nevertheless the debugger will be attached when starting the application. In order to even avoid that ... you need to use "Start without debugging" (Strg+F5).
    – Stefan
    Commented Jul 11, 2017 at 12:05
  • We can select which config we use before publishing (Release, Debug, etc.). What about debugging the application? I mean, when running the app in VS, I am expecting that if I select Debug, it will use debug config, and if I select Release and run the app, it will use release config, but as far as I see it does not. Is it normal?
    – user5871859
    Commented May 8, 2020 at 14:36
  • 1) What about the following issues? There are 3 configs in an ASP.NET MVC project: base (web), debug (web.debug), release (web.release). Assume we set debug and release connection string by transformation to the corresponding config (debug and release). When publishing, we can publish according to our selection in the publish dialog. But, when running application, despite I select Debug, it uses release config (bacause I set debug config in base and debug config), is that normal?
    – user5871859
    Commented May 8, 2020 at 14:53
110

Well, it depends on what language you are using, but in general they are 2 separate configurations, each with its own settings. By default, Debug includes debug information in the compiled files (allowing easy debugging) while Release usually has optimizations enabled.

As far as conditional compilation goes, they each define different symbols that can be checked in your program, but they are language-specific macros.

20

The main difference is when compiled in debug mode, pdb files are also created which allow debugging (so you can step through the code when its running). This however means that the code isn't optimized as much.

4
  • 22
    You can step through the code in release mode too.
    – E Mett
    Commented Jan 28, 2015 at 14:42
  • 14
    pdb files are generated in release mode too Commented May 10, 2017 at 5:24
  • 7
    -1: This is wrong: pdb files should be generated for release build too, since it's very useful to debug a remotely crashing application and doesn't really add an heavy performance cost. In fact it is the default in VS
    – ceztko
    Commented Jan 31, 2018 at 10:20
  • Can I assume this that if we are test running the app, Debug mode is essential and for final built Release mode is recommended?
    – ammad khan
    Commented Mar 31, 2020 at 6:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.