ASP.NET - 在屏幕底部显示应用程序构建日期/信息

标签 asp.net versioning

我有一个 asp.net Web 应用程序,它在其网络内的不同客户服务器上部署了多个版本。我们的一种做法是让客户在遇到问题时通过电子邮件发送屏幕截图。

在旧的 asp.net 1.1 时代,我们可以使用反射获取构建 DLL 的详细信息,并在屏幕上的一个微妙位置显示有关构建日期和编号的信息。

在 .NET 2.0 及更高版本中,构建模型发生了变化,这种机制不再有效。我听说过不同的构建系统,但我真的在寻找最简单的方法,在 3.5 框架上,做这个功能在框架 1.1 上所做的。

  • 每次执行构建时,更新构建日期/时间,并以某种方式更新构建号
  • 能够看到构建时间戳和编号,以显示在屏幕上
  • 尽可能简单地实现
  • 最佳答案

    我们正在使用 .Net 2.0 并从程序集中提取版本信息。也许不理想,但我们使用描述来存储构建日期。

    Assembly assembly = Assembly.GetExecutingAssembly();
    string version = assembly.GetName().Version.ToString();
    string buildDate = ((AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(
        assembly, typeof(AssemblyDescriptionAttribute))).Description;
    

    构建过程使用 asminfo nant 任务生成包含此信息的 AssemblyInfo.cs 文件。
        <asminfo output="Properties\AssemblyInfo.cs" language="CSharp">
            <imports>
                <import namespace="System" />
                <import namespace="System.Reflection" />
                <import namespace="System.Runtime.CompilerServices" />
                <import namespace="System.Runtime.InteropServices" />
            </imports>
            <attributes>
                <attribute type="AssemblyVersionAttribute" value="${assembly.version}" />
                <attribute type="AssemblyInformationalVersionAttribute" value="${assembly.version}" />
                <attribute type="AssemblyDescriptionAttribute" value="${datetime::now()}" />
                ...
            </attributes>
        </asminfo>
    

    关于ASP.NET - 在屏幕底部显示应用程序构建日期/信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/324245/

    相关文章:

    asp.net - 在页面加载时不加载用户控件的最佳方法是什么

    asp.net - 什么是用于性能测试网页/网站的好工具或网站?

    python - 加载入口点的问题,可能连接到包括 dev 标签的版本

    diff - 颜色编码的修订历史

    c# - 以编程方式使用 ListView 转到另一个页面?

    asp.net - 将 linq 查询结果转换为数据表 C#

    scala - 从 taskKey 设置项目版本

    c# - 如何在夜间构建期间自动设置程序集版本?

    .net - 使用修补程序对分布式应用程序的程序集进行版本控制

    ASP.NET 面板未结束