How do I know that adding the Build and Revision values of a given .NE开发者_开发知识库T assembly to new DateTime(2000, 1, 1)
will give me the compile time?
Put another way: how do I know that the [assembly: AssemblyVersion("1.0.*")]
attribute was used for the assembly at compile time?
You don't. The AssemblyVersionAttribute
just stores a bunch of numbers. Those numbers could be:
- Manually assigned
- Auto-incremented
- Based on date and time
- Based on source control revision numbers
There's nothing in AssemblyVersionAttribute
to tell you this.
You could use this:
static string TimestampFromVersion(string version)
{
string[] versionComponents = version.Split('.');
DateTime potentialCompilationDate = (new DateTime(2000, 1, 1)).AddDays(versionComponents[2]).AddSeconds(2 * versionComponents[3]);
return potentialCompilationDate.ToString("dd MMM yyyy, HH:mm:ss");
}
and check against the file's timestamp...
精彩评论