I am a total beginner so pardon me If I do no ask question properly. So, I have one ASP.Net MVC - 5 project. So whenever I make any change I run it on localhost and then after testing I publish it to live server. Now my manager wants me to show on website the version of website I am running. I mean is there some version or build number or something that gets changed for every time we publish the web site. I mean do I need to right click on property on the project and fetch some version number or dll number or something which changes on every publish. please guide me a little here. I don't know how to ask this question properly.
As of now I can see the Date of my website:
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
FileInfo fileInfo = new FileInfo(assembly.Location);
string lastModified = fileInfo.LastWriteTime.Date.ToShortDateString() + " " + fileInfo.LastWriteTime.ToLongTimeString();
Can I fetch other details too regarding the version or something.
I tried two solutions in cshtml
<div>
@{
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
FileInfo fileInfo = new FileInfo(assembly.Location);
string lastModified = fileInfo.LastWriteTime.Date.ToShortDateString() + " " + fileInfo.LastWriteTime.ToLongTimeString();
var e = @ViewContext.Controller.GetType().Assembly.GetName().Version;
string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
</div>
e returns 10.999.999.999
version returns 0.0.0.0
Please guide me.
EDIT:
STEP 1:
So I changed the build number from property tab to 10.999.7.9
Now it changed my assembly.cs to
[assembly: AssemblyVersion("10.999.7.9")]
[assembly: AssemblyFileVersion("10.999.999.999")]
Step 2: AutoIncrement
Now the SO LINK suggests to comment out below two lines
[assembly: AssemblyVersion("10.999.7.9")]
[assembly: AssemblyFileVersion("10.999.999.999")]
and replace with
[assembly: AssemblyVersion("1.0.*")]
So, I am confused here. Shall I comment both the lines. But it will take out the effect of [assembly: AssemblyVersion("10.999.7.9")]