例如,我们有两个团队,共享一个演示服务器。他们一天出版好几次。我如何知道最后一次发布的时间(日期和时间)以及发布人(成员名称)?是否有一些Visual Studio选项或TFS设置来获取发布通知?
发布于 2012-08-24 17:23:19
您可以使用以下代码来获取构建时间戳。
/// <summary>
/// Read the linker timestamp from an executable.
/// </summary>
private DateTime RetrieveLinkerTimestamp(String strFileName)
{
try
{
//Open file
string filePath = strFileName;
const int c_PeHeaderOffset = 60;
const int c_LinkerTimestampOffset = 8;
byte[] b = new byte[2048];
System.IO.Stream s = null;
try
{
s = new System.IO.FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
s.Read(b, 0, 2048);
}
finally
{
if (s != null)
{
s.Close();
}
}
//Get timestamp
int i = System.BitConverter.ToInt32(b, c_PeHeaderOffset);
int secondsSince1970 = System.BitConverter.ToInt32(b, i + c_LinkerTimestampOffset);
//Convert to date/time
DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0);
dt = dt.AddSeconds(secondsSince1970);
dt = dt.AddHours(TimeZone.CurrentTimeZone.GetUtcOffset(dt).Hours);
return dt;
}
catch (Exception ex)
{
throw new Exception("Error in RetrieveLinkerTimestamp", ex);
}
}https://stackoverflow.com/questions/12091650
复制相似问题