Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if an assembly was built using Debug or Release configuration?

I'm starting deployment of my web application and I need to guarantee that all the assemblies that are going to be deployed were built using Release configuration. Our system was developed using C#/.Net 3.5.

Is there any way to achieve this?

like image 427
born to hula Avatar asked Feb 02 '10 18:02

born to hula


People also ask

How do I check if a build is debug or Release Swift?

Check your project's build settings under 'Apple LLVM - Preprocessing', 'Preprocessor Macros' for debug to ensure that DEBUG is being set - do this by selecting the project and clicking on the build settings tab. Search for DEBUG and look to see if indeed DEBUG is being set.

What are debug and Release build configurations?

A Debug configuration supports the debugging of an app, and a Release configuration builds a version of the app that can be deployed.

Is DLL debug or Release?

dll with vcruntime140. dll and ucrtbase. dll, then they were built for release. One other thing that you could look out for is that if you built them with the debug symbols enabled then the debug directory will contain the path to the debug symbol file (even with release builds).


2 Answers

Check this. The idea is that you get the list of assembly attributes using Assembly.GetCustomAttributes() and search for DebuggableAttribute and then find if such attribute has IsJITTrackingEnabled property set.

    public bool IsAssemblyDebugBuild(Assembly assembly)     {         return assembly.GetCustomAttributes(false).OfType<DebuggableAttribute>().Any(da => da.IsJITTrackingEnabled);     } 
like image 54
David Avatar answered Sep 18 '22 14:09

David


I loved that David suggestion, but you could also go this way (AssemblyInfo.cs):

#if DEBUG [assembly: AssemblyDescription("Your application assembly (DEBUG version)")] #else if RELEASE [assembly: AssemblyDescription("Your application assembly (RELEASE version)")] #endif 

This is more human friendly, as anyone can right-click that assembly, to select Properties and go to Details tab.

like image 42
Rubens Farias Avatar answered Sep 21 '22 14:09

Rubens Farias