Para poder obtener la fecha de compilacion de un ensamblado, tendremos que hacer dos cosas
1.- Modificar las líneas AssemblyVersion y AssemblyFileVersion del fichero AssemblyInfo.cs
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.1.*")]
[assembly: AssemblyFileVersion("0.1.1.0")]
Del AssemblyVersion obtendremos la fecha de compilación mientras que la línea AssemblyFileVersion es de donde sacamos la versión del programa (aquí se puede usar cualquier numeración). Para esto usamos el siguiente código
Assembly assembly = Assembly.GetExecutingAssembly();
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
DateTime assemblyDate = new DateTime(2000, 1, 1)
.AddDays(assembly.GetName().Version.Build)
.AddSeconds(assembly.GetName().Version.Revision * 2);
version = string.Format("{0}.{1}.{2} del {3}",
versionInfo.ProductMajorPart,
versionInfo.ProductMinorPart,
versionInfo.ProductBuildPart,
assemblyDate.ToString("dd/MM/yyyy"));
