Is there any virable that gets the time of compilation in the .net environment ?
I am looking for something like __DATE__
in c++ , I need to put in my about window the time of code compilation .
Thanks
Is there any virable that gets the time of compilation in the .net environment ?
I am looking for something like __DATE__
in c++ , I need to put in my about window the time of code compilation .
Thanks
There is no built-in way to do this.
However, you could make a pre-build step that writes the current time to a .cs
file in a static readonly
field.
EDIT: For example:
echo using System; > CompileTime.cs
echo namespace MyCompany.MyProduct { >> CompileTime.cs
echo static class Compilation { >> CompileTime.cs
echo public static readonly DateTime TimeStamp = DateTime.Parse("%date%%time%", System.Globalization.CultureInfo.InvariantCulture); >> CompileTime.cs
echo } >> CompileTime.cs
echo } >> CompileTime.cs
Despite what others have answered, the short answer is Yes.
You can use the version format "1.0.*" for your assembly and the compiler will add the compilation date/time to the end of the version number string - which can easily be read from the ExecutingAssembly.
See here for details.
Short answer: no.
Think about it: time of compilation of what? Last compile? All compilations that have been performed in the last year?
You'll have to time this yourself. Elaborate on what you want to achieve, and people will be able to provide you with a better answer.