-
Notifications
You must be signed in to change notification settings - Fork 0
/
BuildInfo.tt
54 lines (47 loc) · 2.49 KB
/
BuildInfo.tt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="EnvDTE" #>
<#@ import namespace="System.Globalization" #>
<#@ output extension=".cs" #>
<#
const string FMT_DATE_FORMAL = "";
const string FMT_DATE_COMMENT = "MMMM d, yyyy h:mm:ss.ffffff tt";
DateTime dtBuildDate = DateTime.UtcNow;
string strNamespace = String.Empty;
string strFormatDisplay = String.IsNullOrEmpty(FMT_DATE_FORMAL) ? CultureInfo.InstalledUICulture.DateTimeFormat.FullDateTimePattern : FMT_DATE_FORMAL;
var dte = ((IServiceProvider)Host).GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
try
{
strNamespace = ((EnvDTE.Project)((Array)dte.ActiveSolutionProjects).GetValue(0)).Properties.Item("DefaultNamespace").Value.ToString();
}
catch ( Exception /*e*/ )
{
}
#>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// NOTICE: DO NOT EDIT THIS FILE!
//
// This file is autogenerated and your changes will be OVERWRITTEN!
// Edit the corresponding .tt file instead.
//
// Or, better yet, make a lasting contribution by submitting a Pull Request:
// https://github.com/dwcullop/BuildInfo
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
using System;
using System.Reflection;
namespace <#=strNamespace #>
{
public static class BuildInfo
{
private const long BUILD_DATE_BINARY_UTC = 0x<#=dtBuildDate.ToBinary().ToString("x16") #>; // <#=dtBuildDate.ToString(FMT_DATE_COMMENT) #> UTC
private static AssemblyName BuildAssemblyName { get; } = Assembly.GetExecutingAssembly().GetName();
public static DateTimeOffset BuildDateUtc { get; } = DateTime.FromBinary(BUILD_DATE_BINARY_UTC);
public static string ModuleText { get; } = BuildAssemblyName.Name;
public static string VersionText { get; } = "v" + BuildAssemblyName.Version.ToString()
#if DEBUG
+ " [DEBUG]"
#endif
;
public static string BuildDateText { get; } = "<#=dtBuildDate.ToString(strFormatDisplay) #> UTC";
public static string DisplayText { get; } = $"{ModuleText} {VersionText} (Build Date: {BuildDateText})";
}
}