如何检查程序集是使用调试还是发布配置构建的? [英] How to check if an assembly was built using Debug or Release configuration?

查看:24
本文介绍了如何检查程序集是使用调试还是发布配置构建的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开始部署我的 Web 应用程序,我需要保证将要部署的所有程序集都是使用发布配置构建的.我们的系统是使用 C#/.Net 3.5 开发的.

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?

推荐答案

检查 这个.这个想法是,您使用 Assembly.GetCustomAttributes() 获取程序集属性列表并搜索 DebuggableAttribute,然后查找此类属性是否具有 IsJITTrackingEnabled属性集.

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

这篇关于如何检查程序集是使用调试还是发布配置构建的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆