With the "Built in" stuff, you can't, as using 1.0.* or 1.0.0.* will replace the revision and build numbers with a coded date/timestamp, which is usually also a good way.
For more info, see the Assembly Linker Documentation in the /v tag.
As for automatically incrementing numbers, use the AssemblyInfo Task:
AssemblyInfo Task
This can be configured to automatically increment the build number.
There are 2 Gotchas:
- Each of the 4 numbers in the Version string is limited to 65535. This is a Windows Limitation and unlikely to get fixed.
- Using with with Subversion requires a small change:
Retrieving the Version number is then quite easy:
Version v = Assembly.GetExecutingAssembly().GetName().Version;
string About = string.Format(CultureInfo.InvariantCulture, @"YourApp Version {0}.{1}.{2} (r{3})", v.Major, v.Minor, v.Build, v.Revision);
And, to clarify: In .net or at least in C#, the build is actually the THIRD number, not the fourth one as some people (for example Delphi Developers who are used to Major.Minor.Release.Build) might expect.
In .net, it's Major.Minor.Build.Revision.
See my comment above asking for clarification on what you really want. Hopefully this is it:
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
string version = fvi.FileVersion;
Best Answer
OK, I think I get your question better now, you want to see what the build number is, without actually building... as in, how does Visual Studio know what the next number will be when its setting is at * ?
If you use automated build numbers, Lets say you have 1.0.* and VS builds a value such as 1.0.3245.1234
The 3245 is days since Jan 1st, 2000
the 1234 is seconds since midnight, divided by two.
ANSWER TO YOUR EDIT:
The only thing I can think of to get the build number without executing some code within the assembly, or checking the file properties, is to make some sort of post build event, that checks the properties of the assembly and pops up a message box displaying it, or better yet, write a comment to the top of the AssemblyInfo.cs file with the build number