Determining 'Build' date of a solution

  • Thread starter Thread starter Roger Helliwell
  • Start date Start date
R

Roger Helliwell

Hey gang,

What's the best way to implement a Build version (or "last updated"
date) in my web-app? I have a footer in my master page that displays
the application's name and copyright info etc. I'd like to add a Build
version and build date as well. (Without hardcoding it obviously.)

At first I thought I'd just take the timestamp of the web.config, but
my web.config doesn't change that much. Is there an easy way to
determine what day the entire web-app was built? (or deployed might be
more accurate.)

My web solution is fairly large, about 40 aspx pages, and 12
class-library projects -- so perhaps I should start thinking about
implementing a versioning regime as well.

Any thoughts on this? Thanks.

Roger
 
Roger,
Here's how you would get the build version:

System.Reflection.Assembly asm =
System.Reflection.Assembly.GetExecutingAssembly(); // Get our assembly;
System.Version version = asm.GetName().Version;
string build = version.ToString(); //

To get the date, you can do it this way, but you have to set the correct
FileIOPermissions;

System.IO.FileInfo inf = new System.IO.FileInfo(asm.Location); // get the
location of our executing assembly
DateTime dt = inf.LastWriteTime();
string buildDate = dt.ToString();

Hope that helps.

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top