forked from linuxgurugamer/StationKeeping
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssemblyVersion.tt
96 lines (80 loc) · 2.34 KB
/
AssemblyVersion.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
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
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ import namespace="System.IO" #>
<#@ output extension=".cs" #>
<#@ assembly name="EnvDTE" #><# /* This assembly provides access to Visual Studio project properties. */ #>
<#
// Instructions
// 1. Add a new Text Template to the project
// 2. Copy this file into the new template
// 3. Update the string: versionfile with the complete path to the .version file
// 4. Remove the following line from the file AssemblyInfo.cs (usually located in the "Property" folder inside your C# project):
// [assembly: AssemblyVersion("1.0.0.0")]
// 5. Add the following to the PreBuild steps:
//
// set textTemplatingPath="%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\Common7\IDE\texttransform.exe"
// %textTemplatingPath% "$(ProjectDir)AssemblyVersion.tt"
int major = 0;
int minor = 0;
int build = 0;
int patch = 0;
bool versionSection = false;
int i = 0;
int i2 = 0;
string s;
//
// Update the following with the complete path to the .version file
//
string versionfile = @"CompletePathTo.version";
if (!File.Exists(versionfile))
{
Write("File: " + versionfile + " missing\n");
}
try
{
foreach (var line in File.ReadAllLines(versionfile))
{
if (line != null)
{
if (!versionSection)
{
if (line.Contains("\"VERSION\""))
versionSection = true;
}
else
{
if (line.Contains("}"))
versionSection = false;
i = line.IndexOf(":");
i2 = line.IndexOf(",");
if (i2 == -1)
i2 = line.Length;
if (i >= 0 && i2 >= 0)
{
s = line.Substring(i + 1, i2 - i - 1);
if (line.Contains("MAJOR"))
Int32.TryParse(s, out major);
if (line.Contains("MINOR"))
Int32.TryParse(s, out minor);
if (line.Contains("PATCH"))
Int32.TryParse(s, out patch);
if (line.Contains("BUILD"))
Int32.TryParse(s, out build);
}
}
}
}
}
catch
{
major = 1;
minor = 0;
patch = 0;
build = 0;
}
//Write("File done");
#>
// This code was generated by a tool. Any changes made manually will be lost
// the next time this code is regenerated.
//
using System.Reflection;
[assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= patch #>.<#= build #>")]