The project is hosted on a tfs server and I need to access the build number which I assume is automatically generated when ever you build a project.
I need to retrieve that build number and display it on the web pages so that QAs and testing people know exactly which build they are working on.
I found how to create customize build numbers in the following link: http://msdn.microsoft.com/en-us/library/aa395241(v=vs.100).aspx
but it dose not solve my problem as I do not have access to the build definition file.
I am looking for some kind of post deployment task which can access the build number or may be generate one and probably write it down to a file, from where I can read it. I don't know if that makes any sense as this is my first time working on .Net
You could do something like this:
Assembly assembly = Assembly.GetExecutingAssembly();
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
string version = fvi.FileVersion;
or alternatively if you have multiple assemblies then you can use
Assembly.GetAssembly(typeof(SomeObject))
where SomeObject
is declared in the assembly you want to get the version of.