12

in AssemblyInfo.cs file I have following subection:

#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif

Where this information can be seen after assembly is built ? Since there is nothing about it in file details:

enter image description here

where else can it be found ?

Regards

jwaliszko
  • 16,942
  • 22
  • 92
  • 158

3 Answers3

13

You can use reflection to get this information. I believe it would be something like the following.

Assembly assembly = Assembly.GetExecutingAssembly();
object[] attributes = assembly.GetCustomAttributes(true);
var config = attributes.OfType<AssemblyConfigurationAttribute>().FirstOrDefault();
if (config != null) {
        Debug.WriteLine(config.Configuration);
}

Thinking about it further is this your intent?

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

The blogpost linked from the top answer shows a better way to determine if the assembly is Debuggable: http://stevesmithblog.com/blog/determine-whether-an-assembly-was-compiled-in-debug-mode/

One answer indicates that if you use the AssemblyDescription attribute to conditionally include Release/Debug in the text you can have that information in Windows Explorer.

Community
  • 1
  • 1
j0tt
  • 1,108
  • 1
  • 7
  • 16
  • 1
    The third line I would replace with `var config = attributes.OfType().FirstOrDefault();`. Then you don't need the cast and it looks a bit cleaner imho. – Philipp M Jun 24 '15 at 12:44
3

You can use ILDASM.exe to look at the compiled assembly. See http://msdn.microsoft.com/en-us/library/ceats605.aspx for info on using ILDASM.exe.

Or you may use Reflection to look at it via code, such as System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes()

Shawn
  • 8,374
  • 5
  • 37
  • 60
1

The Windows Explorer property sheet pulls that information from the win32 VERSIONINFO resources. A number of assembly attributes can be mapped to win32 resource fields (and will be set by the build) but it may be that the AssemblyConfiguration attribute is not one of them.

If you want to look at all assembly attributes, including those that don't set win32 resource fields, .NET Reflector is one option.

Community
  • 1
  • 1
dkackman
  • 15,179
  • 13
  • 69
  • 123