Is there any connection between debug = "true" compilation and "release" publishing mode

Do I need to set debug='false'

 <compilation debug="false" targetFramework="4.0" /> 

Even if you publish my code in release mode .

Change 1

As mentioned in the MSDN compilation review. This is done in two phases.

  • At the first stage, it compiles the code into one or several assemblies
  • In the second, pahse translates MSIL into processor-specific instructions for the processor on the computer on which the application is running

Does the publication code use phase 1 part and
<compilation .... means phase 2.

+6
source share
6 answers

I do not quite understand your question. If you ask that you need to manually set debug = 'false', then the answer will depend on the fact if there are files with a configuration conversion in the project. The standard Visual Studio web project template includes two configuration conversion files: Web.Debug.config and Web.Release.config. These files contain the configuration transform that should be used when publishing the code. This is an example of the default Web.Release.config file:

 <?xml version="1.0"?> <!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 --> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <!-- In the example below, the "SetAttributes" transform will change the value of "connectionString" to use "ReleaseSQLServer" only when the "Match" locator finds an atrribute "name" that has a value of "MyDB". <connectionStrings> <add name="MyDB" connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> </connectionStrings> --> <system.web> <compilation xdt:Transform="RemoveAttributes(debug)" /> <!-- In the example below, the "Replace" transform will replace the entire <customErrors> section of your web.config file. Note that because there is only one customErrors section under the <system.web> node, there is no need to use the "xdt:Locator" attribute. <customErrors defaultRedirect="GenericError.htm" mode="RemoteOnly" xdt:Transform="Replace"> <error statusCode="500" redirect="InternalError.htm"/> </customErrors> --> </system.web> </configuration> 

So, if you have a Web.Release.config conversion file with content similar to the above, and you use Visual Studio's publishing capabilities (or in accordance with msbuild's goals), then the debug = 'true' attribute will be deleted when your project is published to release mode.

There are many advantages to removing debug = 'true' from the web configuration. These settings affect not only the compiled DLLs, but also which version of MS Ajax scripts will be loaded (if you use ASP.NET and Script Manager web forms). In the debug version of the MS Ajax library, there are many checks (checking arguments, etc.) that are removed from the release script version. This is why the debug version is slow.

+5
source

Yes, you need to use debug = "false".

ASP.Net parses .aspx or views and creates some dll that is different from the one you compile with Visual Studio. This parameter is for these dlls.

ASP.NET compilation overview http://msdn.microsoft.com/en-us/library/ms178466(v=vs.100).aspx

+3
source

There are many advantages to discussing debug=true vs debug=false in a production system to debug debugging when publishing to production. Other answers and comments are described in more detail on this (one big advantage that I noticed in MVC4 applications is that JS and CSS packages are minimized when debugging is disabled).

The question that publication in Release mode is sufficient, read below:

If you use ready-made conversion files that come with the new ASP.NET project, then no, you do not need to manually install it. However, if you do not have transformation files or you do not use them, then during production release you must change this parameter.

Basically, when you publish an ASP.NET website, what it will do is create an application, apply the corresponding web.config conversion (based on the configuration selected in the "Settings" section when using "Publish Website" which I assume is where you select the Release mode) and then publish the code in the specified location.

Typically, to get started with transformations, when you create an ASP.NET application in Visual Studio, you will be presented with two transformations for your web.config: web.Debug.config and web.Release.config (you can see them by clicking the extension symbol next to your web.config file).

If you don’t have any transformations, you can create them by right-clicking on the web.config file and selecting “Add Transform Config”, and the transformation files will be created for your various assembly configurations that you have in your solution.

As Maxim Kornilov noted in his answer, out of the box web.Release.config contains this important transformation line: <compilation xdt:Transform="RemoveAttributes(debug)" /> , which tells the application to remove the debug attribute from the <compilation tag, which will publish applications with debugging disabled.

Note. if you do not see that RemoveAttributes(debug) in the configuration conversion that you select when publishing, then the code can be published in debug mode.

If you really want to be sure how the conversion works, review the contents of web.config after posting and you will see the output of the conversion

In addition, there is a tool at http://webconfigtransformationtester.apphb.com/ that allows you to check how the conversion of web.config affects your web.config file.

Finally, I am a big fan of using the build server and am going to publish my code when it is ready to work (fewer people need direct access to the server this way), so converting web.config helps me quite a bit, because I I can change the connection strings based on the environment I'm deploying to, as well as to manage warning messages, etc. for different environments (for example, warning: test system, do not enter real data). Using transformations, the main collection of settings can remain in the web.config file (along with the local dev settings, since pressing F5 usually does not apply the transformation unless you publish it locally for testing), and each environment has its own configuration transformation that lives in source control, and with the same branch, the code can be easily deployed in several environments without the need to change any code.

+1
source

Theory

This 2006 article lists the effects of debug="true" :

  • ASP.NET requests will not be disabled: for obvious debugging purposes
  • Batch compilation disabled: pages and controls compiled into separate assemblies
  • Code optimization: JIT compiler generates more efficient code

The number 3. is basically the same as compiling Release mode.

Code References

To give him some more research, I released Re # on System.Web.Configuration.CompilationSection.Debug in one of my 4.0 web projects. Found:

  • System.Web.Configuration.BrowserCapabilitiesCodeGenerator.GenerateAssembly
  • System.Web.Configuration.CompilationSection.GetCompilerInfoFromExtension
  • System.Web.Configuration.CompilationSection.GetCompilerInfoFromLanguage
  • System.Web.Compilation.CompilationUtil.GetRecompilationHash
  • System.Web.HttpRuntime.InitDebuggingSupport
  • System.Web.Compilation.CompilationUtil.IsDebuggingEnabled

All this, apparently, refers to the three points mentioned above.

Runtime Effects

Note that the debug flag affects

While the network effect is basically the same, changing the flag does not have any optimization effect on any code that does not compile on the fly (for example, with wdproj precompilation).

Ligaments

In addition, there is at least 1 other use of the debug flag: resource packages . The combined JS and CSS will be output unchanged when the debug flag in the application / web configuration is enabled.

+1
source

You do not need to specify debug = "false". You can just drop it and leave

 <compilation targetFramework="4.5" /> 

Debugging IIS asumes is false.

+1
source

You must. The debug="true" switch should only be used during development.

0
source

Source: https://habr.com/ru/post/947291/


All Articles