forked from KSP-ModularManagement/ModuleManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVersion.tt
More file actions
98 lines (90 loc) · 2.54 KB
/
Copy pathVersion.tt
File metadata and controls
98 lines (90 loc) · 2.54 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<# /* This file is licensed under the Do What the F* You Want to Public License ( http://www.wtfpl.net )
* by LisiasT. http://ksp.lisias.net
*
* You are allowed to copy, modify and use this file unrestrictly. Just don't bother me with ridiculous demands. Please. :)
*/
#>
<# // from https://docs.microsoft.com/en-us/visualstudio/modeling/walkthrough-generating-code-by-using-text-templates?view=vs-2017 #>
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ output extension=".cs" #>
<#@ import namespace="System.IO" #>
<#
string PROJECT_NAME = "ModuleManager";
int major = 0;
int minor = 0;
int patch = 0;
int build = 0;
try
{
string file = this.Host.ResolvePath("../../../" + PROJECT_NAME
#if KSP12
+ ".122"
#else
+ ""
#endif
+ ".version");
string text = File.ReadAllText(file);
{
int i = text.IndexOf("\"VERSION\"", System.StringComparison.Ordinal);
int j = text.IndexOf("}", i + 1, System.StringComparison.Ordinal);
text = text.Substring(i, j-i+1);
}
try
{
int i = text.IndexOf("\"MAJOR\"", System.StringComparison.Ordinal);
while (!Char.IsNumber(text[i])) ++i;
int j = i;
while (Char.IsNumber(text[j])) ++j;
Int32.TryParse(text.Substring(i,j-i), out major);
}
catch { }
try
{
int i = text.IndexOf("\"MINOR\"", System.StringComparison.Ordinal);
while (!Char.IsNumber(text[i])) ++i;
int j = i;
while (Char.IsNumber(text[j])) ++j;
Int32.TryParse(text.Substring(i,j-i), out minor);
}
catch { }
try
{
int i = text.IndexOf("\"PATCH\"", System.StringComparison.Ordinal);
while (!Char.IsNumber(text[i])) ++i;
int j = i;
while (Char.IsNumber(text[j])) ++j;
Int32.TryParse(text.Substring(i,j-i), out patch);
}
catch { }
try
{
int i = text.IndexOf("\"BUILD\"", System.StringComparison.Ordinal);
while (!Char.IsNumber(text[i])) ++i;
int j = i;
while (Char.IsNumber(text[j])) ++j;
Int32.TryParse(text.Substring(i,j-i), out build);
}
catch { }
}
catch (Exception e)
{
Write("Error: " + e.Message);
}
#>
// Automatically generated code. Any changes will be lost!
namespace <#= PROJECT_NAME #>
{
public static class Version
{
public const int major = <#= major #>;
public const int minor = <#= minor #>;
public const int patch = <#= patch #>;
public const int build = <#= build #>;
public const string Number = "<#= major #>.<#= minor #>.<#= patch #>.<#= build #>";
#if KSP12
public const string Text = Number + " /L Experimental for KSP 1.2.2 Beta";
#else
public const string Text = Number + " /L Experimental";
#endif
}
}