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);
}