Build Date for MVC or Visual Studio project

Shamelessly stolen from here

Project, create new folder Resources

Project, Properties: Build Events, Pre-Build event command line

echo %date% %time% > "$(ProjectDir)\Resources\BuildDate.txt"

Build your Project

Project, Resources: Create Default Resources File

..Add Resource, Existing File, …\Resources\BuildDate.txt

To read the build date, e.g. in a controller

protected override IAsyncResult BeginExecute(RequestContext requestContext, AsyncCallback callback, object state)
 {

ViewBag.BuildDate = Properties.Resources.BuildDate;

...

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Website by WNW Digital