如何检查是否装配使用调试或释放结构建成的? [英] How to check if an assembly was built using Debug or Release configuration?

查看:124
本文介绍了如何检查是否装配使用调试或释放结构建成的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始我的web应用程序的部署,我需要保证所有将要部署的组件是使用Release配置建。我们的系统开发使用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>().Select(da => da.IsJITTrackingEnabled).FirstOrDefault();
    }

这篇关于如何检查是否装配使用调试或释放结构建成的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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