Is there some clever way of getting the date and time of when the dll was built/compiled?
I’m using the assembly version numbering and reflection to retrieve and display this info when the app is deployed. But in some scenarios it would be more convenient to know when then dll was actually compiled rather than the auto incrementing version number. I don’t think the modified date on the dll file itself is reliable due to the way the app is deployed.
Dim assemblies = AppDomain.CurrentDomain.GetAssemblies
Dim assemblyName As String
Dim assemblyVersion As String
For Each assembly In assemblies
assemblyName = assembly.GetName.Name.ToString
assemblyVersion = assembly.GetName.Version.ToString
' How to get the date/time of the build??
' ...
Next
Any suggestions?
In computer science, compile time (or compile-time) describes the time window during which a computer program is compiled.
If we have to wait for the compilation part, that slows down the entire workflow. And time is money. If one manages to optimise the compilation time down to a few milliseconds, then we can move on to testing our changes. If we need to wait hours until that step, that creates a bottleneck in the development.
C++ Compile-time Constant: These are the constants whose respective value is known or computed at the time of compilation of source code. Compile-time constants are faster than run-time constants but are less flexible than run-time constants.
Particularly for 1., compile time really matters for us. Anything we can do to improve compile time will increase our users' experience when editing their gameplay code and seeing what effect it has on the scene they are using.
If you set the assembly version (usually in AssemblyInfo.cs) to Major.Minor.*
(e.g. 1.0.*
), then you can probably retrieve the build date at runtime with something like this:
var version = Assembly.GetExecutingAssembly().GetName().Version;
DateTime buildDate = new DateTime(2000, 1, 1)
.AddDays(version.Build)
.AddSeconds(version.Revision*2);
When using a *
for the third and fourth part of the assembly version, then these two parts are set automatically at compile time to the following values:
Oh, and you have to take care of daylight saving time yourself (e.g. add one hour if it's daylight saving time).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With