-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssemblyInfo.cs
More file actions
45 lines (36 loc) · 1.38 KB
/
AssemblyInfo.cs
File metadata and controls
45 lines (36 loc) · 1.38 KB
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
using System.Reflection;
using System.Runtime.InteropServices;
namespace ptr727.LanguageTags.Create;
internal static class AssemblyInfo
{
internal static string AppVersion => $"{AppName} : {FileVersion} ({BuildType})";
internal static string RuntimeVersion =>
$"{RuntimeInformation.FrameworkDescription} : {RuntimeInformation.RuntimeIdentifier}";
internal static string BuildType =>
#if DEBUG
"Debug";
#else
"Release";
#endif
internal static string AppName => GetAssembly().GetName().Name ?? string.Empty;
internal static string InformationalVersion =>
// E.g. 1.2.3+abc123.abc123
GetAssembly()
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
?.InformationalVersion
?? string.Empty;
internal static string FileVersion =>
// E.g. 1.2.3.4
GetAssembly().GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version
?? string.Empty;
internal static string ReleaseVersion =>
// E.g. 1.2.3 part of 1.2.3+abc123.abc123
// Use major.minor.build from informational version
InformationalVersion.Split('+', '-')[0];
private static Assembly GetAssembly()
{
Assembly? assembly = Assembly.GetEntryAssembly();
assembly ??= Assembly.GetExecutingAssembly();
return assembly;
}
}