1<#@ template debug="false" hostspecific="true" language="C#" #> 2<#@ import namespace="System" #> 3<#@ import namespace="System.Diagnostics" #> 4<#@ import namespace="System.IO" #> 5<#@ import namespace="System.Text" #> 6<#@ output extension=".cs" #> 7<# 8 int major = 1; 9 int minor = 7; 10 string version = string.Empty; 11 string infoVersion = string.Empty; 12 13 try 14 { 15 if (!string.IsNullOrEmpty(ExecuteGitCommand("describe --tags --exact-match"))) 16 { 17 version = ExecuteGitCommand("describe --tags"); 18 infoVersion = version; 19 } 20 } 21 catch 22 { 23 version = string.Empty; 24 infoVersion = string.Empty; 25 } 26 27 if (string.IsNullOrEmpty(version)) 28 { 29 try 30 { 31 //This is a quick and easy hack to increment the build number once a day if built 32 int build = (int)(DateTime.UtcNow - new DateTime(2019, 10, 29)).TotalDays; 33 //The revision represents the total number of minutes since midnight when this version was built. 34 int revision = (int)DateTime.Now.TimeOfDay.TotalMinutes; 35 version = string.Format("{0}.{1}.{2}.{3}", major, minor, build, revision); 36 infoVersion = string.Format("{0}-{1}", version, Environment.UserName); 37 } 38 catch 39 { 40 version = string.Format("{0}.{1}.0.0", major, minor); 41 infoVersion = string.Format("{0}-unknown", version); 42 } 43 } 44 #> 45 46 // This code was generated by a tool. Any changes made manually will be lost 47 // the next time this code is regenerated. 48 // 49 50using System; 51using System.Reflection; 52using System.Runtime.CompilerServices; 53using System.Runtime.InteropServices; 54 55[assembly: AssemblyTitle("openBVE")] 56[assembly: AssemblyProduct("openBVE")] 57[assembly: AssemblyCopyright("The openBVE Project")] 58[assembly: ComVisible(false)] 59[assembly: AssemblyVersion("<#= version #>")] 60[assembly: AssemblyInformationalVersion("<#= infoVersion #>")] 61[assembly: AssemblyFileVersion("<#= version #>")] 62[assembly: CLSCompliant(false)] 63[assembly: InternalsVisibleTo("RouteManager2")] 64 65namespace OpenBve { 66 internal static partial class Program { 67 internal const string VersionSuffix = ""; 68 } 69} 70 71<#+ 72 public string ExecuteGitCommand(string arg) 73 { 74 using (Process process = new Process()) 75 { 76 process.StartInfo.FileName = "git"; 77 process.StartInfo.Arguments = arg; 78 process.StartInfo.UseShellExecute = false; 79 process.StartInfo.RedirectStandardOutput = true; 80 process.StartInfo.StandardOutputEncoding = Encoding.UTF8; 81 process.StartInfo.RedirectStandardError = true; 82 process.StartInfo.StandardErrorEncoding = Encoding.UTF8; 83 process.Start(); 84 return process.StandardOutput.ReadToEnd().Trim(); 85 } 86 } 87 #> 88