ASP.NET - 显示应用程序的构建日期/屏幕底部的信息 [英] ASP.NET - show application build date/info at the bottom of the screen

查看:108
本文介绍了ASP.NET - 显示应用程序的构建日期/屏幕底部的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有有许多部署在其网络内不同客户的服务器版本的asp.net web应用程序。我们有一个做法是,客户的电子邮件截图,当他们有问题。

在旧asp.net1.1天,我们可以抢在构建DLL的详细信息,使用反射,并显示有关在一个微妙的位置生成日期和编号屏幕上的信息。

使用.NET 2.0和更高版本,构建模型改变,这种机制不再起作用。我听到不同的构建系统在那里,但我真的在寻找最简单的方法,对3.5框架,做此功能的框架1.1做了。


  1. 执行构建时,都会更新生成日期/时间,并以某种方式更新版本号

  2. 可以看到构建时间戳和数量,以显示在屏幕上

  3. 是简单实现尽可能


解决方案

我们使用的是.NET 2.0和拉版本信息出来的组装。或许并不理想,但我们使用说明存储构建日期。

 大会总成= Assembly.GetExecutingAssembly();
字符串版本= assembly.GetName()Version.ToString()。
字符串创建日期=((AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(
    。组装的typeof(AssemblyDescriptionAttribute)))的说明;

构建过程使用asminfo恶性任务生成包含此信息AssemblyInfo.cs文件。

 < asminfo输出=属性\\ AssemblyInfo.cs中的语言=CSHARP>
<进口>
<进口命名空间=系统/>
<进口命名空间=的System.Reflection/>
<进口命名空间=System.Runtime.CompilerServices/>
<进口命名空间=System.Runtime.InteropServices/>
< /进口>
<&属性GT;
<属性类型=AssemblyVersionAttribute值=$ {} assembly.version/>
<属性类型=AssemblyInformationalVersionAttribute值=$ {} assembly.version/>
<属性类型=AssemblyDescriptionAttribute值=$ {日期时间::现在()}/>
...
< /属性>
< / asminfo>

I have a asp.net web application which has a number of versions deployed on different customer servers inside their networks. One practice that we have is to have clients email screenshots when they have issues.

In the old asp.net 1.1 days, we could grab details of the build DLL, using reflection, and show info about the build date and numbering on the screen in a subtle location.

With .NET 2.0 and higher, the build model changed, and this mechanism no longer works. I have heard of different build systems out there, but I'm really looking for the simplest way, on the 3.5 framework, to do what this functionality did on framework 1.1.

  1. Every time a build is performed, update the build date/time, and somehow update the build number
  2. Be able to see the build timestamp and number, to display on the screen
  3. be as simple to implement as possible

解决方案

We are using .Net 2.0 and pull the version information out of the assembly. Perhaps not ideal, but we use the description to store the build date.

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

The build process uses asminfo nant task to generate the AssemblyInfo.cs file that contains this information.

	<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 - 显示应用程序的构建日期/屏幕底部的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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