mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-25 20:05:27 +00:00
Use current date as the 'readable' version (on installer/zip).
This commit is contained in:
parent
d889d6ceaa
commit
9775253051
|
@ -34,39 +34,43 @@ namespace Build.UpdateVersion
|
|||
{
|
||||
const string Major = "1";
|
||||
const string Minor = "0";
|
||||
static string Version = "{0}.{1}.{2}";
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
GenerateVersionInfo("../../Version.txt");
|
||||
GenerateAssemblyInfo("../GlobalAssemblyInfo.cs");
|
||||
DateTime now = DateTime.UtcNow;
|
||||
GenerateVersionInfo(now, "../../Version.txt");
|
||||
GenerateAssemblyInfo(now, "../GlobalAssemblyInfo.cs");
|
||||
}
|
||||
|
||||
static void GenerateVersionInfo(string file)
|
||||
static void GenerateVersionInfo(DateTime now, string file)
|
||||
{
|
||||
// If the file does not exist, create it.
|
||||
string version = null;
|
||||
|
||||
if (System.IO.File.Exists(file))
|
||||
{
|
||||
string[] lines = System.IO.File.ReadAllLines(file);
|
||||
if (lines.Length > 0 && !String.IsNullOrEmpty(lines[0]))
|
||||
{
|
||||
Version = lines[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Build number is defined as the number of days since 1/1/2010.
|
||||
// Revision number is defined as the fraction of the current day, expressed in seconds.
|
||||
double timespan = DateTime.UtcNow.Subtract(new DateTime(2010, 1, 1)).TotalDays;
|
||||
string build = ((int)timespan).ToString();
|
||||
string revision = ((int)((timespan - (int)timespan) * UInt16.MaxValue)).ToString();
|
||||
Version = String.Format("{0}.{1}.{2}.{3}", Major, Minor, build, revision);
|
||||
System.IO.File.WriteAllLines(file, new string[] { Version });
|
||||
version = lines[0];
|
||||
}
|
||||
}
|
||||
|
||||
static void GenerateAssemblyInfo(string file)
|
||||
// If the file does not exist, create it.
|
||||
if (version == null)
|
||||
{
|
||||
version = now.ToString("u").Split(' ')[0];
|
||||
System.IO.File.WriteAllLines(file, new string[] { version });
|
||||
}
|
||||
}
|
||||
|
||||
static void GenerateAssemblyInfo(DateTime now, string file)
|
||||
{
|
||||
// Build number is defined as the number of days since 1/1/2010.
|
||||
// Revision number is defined as the fraction of the current day, expressed in seconds.
|
||||
double timespan = now.Subtract(new DateTime(2010, 1, 1)).TotalDays;
|
||||
string build = ((int)timespan).ToString();
|
||||
string revision = ((int)((timespan - (int)timespan) * UInt16.MaxValue)).ToString();
|
||||
|
||||
File.WriteAllLines(file, new string[]
|
||||
{
|
||||
"// This file is auto-generated through Source/Build.Tasks/GenerateAssemblyInfo.cs.",
|
||||
|
@ -83,7 +87,7 @@ namespace Build.UpdateVersion
|
|||
"[assembly: AssemblyCopyright(\"Copyright © 2006 - 2010 the Open Toolkit Library\")]",
|
||||
"[assembly: AssemblyTrademark(\"OpenTK\")]",
|
||||
String.Format("[assembly: AssemblyVersion(\"{0}.{1}.0.0\")]", Major, Minor),
|
||||
String.Format("[assembly: AssemblyFileVersion(\"{0}\")]", Version)
|
||||
String.Format("[assembly: AssemblyFileVersion(\"{0}.{1}.{2}.{3}\")]", Major, Minor, build, revision),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue