Friday, December 31, 2010

ASP.NET : Assembly Build Date On Web Pages

In one of our Projects we needed to display the build date of the Web application on a web page.   There are other ways like using a custom build task to generate this information but we just used a small tweak based on the way Assembly Version information is filled in, to extract the build date and time. 

Just replace the build and revision numbers in AssemblyVersion in AssemblyInfo.cs with ‘*’. So VS will fill in the build date (as number of days from 1/1/2000) and time as seconds elapsed from midnight. Now go and extract date and time from this info.

We always do clean and full builds, so this always reflects the build date/time for all pages.  May not be a perfect solution but it serves our purpose.

Sample Code :