0
응용 프로그램에 표시 할 빌드의 타임 스탬프를 작성하는 빌드 프로세스에서 쉽게 구성 할 수있는 방법이 있습니까? "이 페이지는 마지막 업데이트 날짜 : 2010 년 6 월 26 일 "응용 프로그램 컴파일 타임 스탬프 삽입
응용 프로그램에 표시 할 빌드의 타임 스탬프를 작성하는 빌드 프로세스에서 쉽게 구성 할 수있는 방법이 있습니까? "이 페이지는 마지막 업데이트 날짜 : 2010 년 6 월 26 일 "응용 프로그램 컴파일 타임 스탬프 삽입
한 가지 해결책은 빌드 중에이 정보를 어셈블리 특성에 포함시키는 것입니다. 당신은 MSBuild에서 커뮤니티 작업 시간과 어셈블리 정보 작업을 사용하여이 작업을 수행 할 수 있습니다
<Time>
<Output TaskParameter="Month" PropertyName="Month" />
<Output TaskParameter="Day" PropertyName="Day" />
<Output TaskParameter="Year" PropertyName="Year" />
<Output TaskParameter="Hour" PropertyName="Hour" />
<Output TaskParameter="Minute" PropertyName="Minute" />
<Output TaskParameter="Second" PropertyName="Second" />
</Time>
및
<AssemblyInfo CodeLanguage="CS"
OutputFile="$(MSBuildProjectDirectory)\GlobalInfo.cs"
AssemblyDescription="This page was last updated: $(Month)/$(Day)/$(Year)"
/>
당신은 프로젝트의 소스 파일 (이 예에서는 GlobalInfo.cs)를 포함한다. 코드에서이 값에 액세스하려면 다음과 같이 사용하십시오.
public static string GetAssemblyDescription(Type t)
{
string result = String.Empty;
var items = t.Assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
if (items != null && items.Length > 0)
{
AssemblyDescriptionAttribute attrib = (AssemblyDescriptionAttribute)items[0];
result = attrib.Description;
}
return result;
}
Type t = typeof(MyClass);
string description = GetAssemblyDescription(t);
Console.WriteLine(description);