This question already has an answer here:
I want to store a set of integers that get auto incremented at build time:
int MajorVersion = 0;
int MinorVersion = 1;
int Revision = 92;
When I compile, it would auto-increment Revision
. When I build the setup project, it would increment MinorVersion
(I'm OK with doing this manually). MajorVersion
would only be incremented manually.
Then I could display a version number in menu Help/About to the user as:
Version: 0.1.92
How can this be achieved?
This question asks not only how to have an auto-incrementing version number, but also how to use that in code which is a more complete answer than others.
Here's the quote on AssemblyInfo.cs from MSDN:
This effectively says, if you put a 1.1.* into assembly info, only build number will autoincrement, and it will happen not after every build, but daily. Revision number will change every build, but randomly, rather than in an incrementing fashion.
This is probably enough for most use cases. If that's not what you're looking for, you're stuck with having to write a script which will autoincrement version # on pre-build step
You can do more advanced versioning using build scripts such as Build Versioning
Star in version (like "2.10.3.*") - it is simple, but the numbers are too large
AutoBuildVersion - looks great but its dont work on my VS2010.
@DrewChapin's script works, but I can not in my studio set different modes for Debug pre-build event and Release pre-build event.
so I changed the script a bit... commamd:
and script (this works to the "Debug" and "Release" configurations):