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 = RetrieveGitRevision() ?? RetrieveSvnRevision() ?? RetrieveBzrRevision() ?? RetrieveSeconds(timespan);
revision = revision.Trim();
Console.WriteLine("Build timestamp was: " + build);
Console.WriteLine("Revision detected was: " + revision);
File.WriteAllLines(file, new string[]
{
"// This file is auto-generated through Source/Build.Tasks/GenerateAssemblyInfo.cs.",
"// Do not edit by hand!",
"",
"using System;",
"using System.Reflection;",
"using System.Resources;",
"using System.Runtime.CompilerServices;",
"using System.Runtime.InteropServices;",
"",
"[assembly: AssemblyCompany(\"The Open Toolkit Library\")]",
"[assembly: AssemblyProduct(\"The Open Toolkit Library\")]",
"[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}.{1}.{2}.{3}\")]", Major, Minor, build, revision),
});
}