-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssemblyFileVersion.t4
50 lines (43 loc) · 1.74 KB
/
AssemblyFileVersion.t4
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
<#@ template debug="true" hostspecific="true" language="C#" #>
<#@ output extension=".cs" #>
<#@ import namespace="System.IO" #>
<#
int revisionNumber ;
DateTime time = DateTime.Now;
string format = "MMdd";
string CurrentDate = time.ToString(format);
string YearFormat = "yyyy";
string CurrentYear = time.ToString(YearFormat);
string AssembleyFileVersion = Host.ResolvePath("AssemblyFileVersion.txt");
try
{
//If we cannot find the file, the revision number is set to zero,
//so even if the file doesn't exists the generation will run anyway.
//NOTE: we suppose we're not messing with the generated file
using (StreamReader f = new StreamReader(AssembleyFileVersion))
{
//We're reading the previous revision number; in order to make the
//code as simple as we can, we're just going to rewrite it on the first row, commented.
//This is not elegant, but it's simple enough and quite effective.
Int32.TryParse(f.ReadLine(), out revisionNumber) ;
revisionNumber ++;
}
}
catch
{
revisionNumber = 0 ;
}
using (StreamWriter Sw = new StreamWriter(AssembleyFileVersion))
{
Sw.WriteLine(revisionNumber.ToString());
}
#>
//<#=revisionNumber.ToString()#>
//
// 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("2.19.<#= revisionNumber.ToString("D3") #>.<#= CurrentDate #>")]
[assembly: AssemblyFileVersion("2.19.<#= revisionNumber.ToString("D3") #>.<#= CurrentDate #>")]
[assembly: AssemblyCopyright("Copyright © 2012 - <#= CurrentYear #>")]