Some points to note before we start. I will keep this example to VS2010 (but i don’t see any reason why this trick can’t be applied to VS2012 or 2013) . This setup does not involve any add-ins or installations. I will provide complete code which requires to just make a little change in target project setup and the setup will be ready to go. This setup should work whether or not you have any sourcecontrol – GIT, VSS, TFS – connected to your project.
If you are my type you would wish to tag your builds and deliverable incrementally. For large teams and pro grade development environment there are advanced solutions available to automate the process. But what about indie developers? I don’t know why “*” in build field in Project setting does not auto-increment it but it did not work for me in VS2010 pro, WP project. Even if it did, it serves no practical purpose for the lack of control. Also, for no-frill setup there are some VS Add-ins available which provide auto-increment build capabilities. I tried them and some totally did not work (VS broke) and others had severe lack of functionality. So let’s see what I want this setup to do.
Increment My Build Number
- Automatically, transparently increment build number of my project, any project.
- Let me control, through setting, when to increment build – Debug | Release | (other)
- Ability to start from a custom number
- Let me reset the build number
- Complete Version Number
- Date and time of the build
- Configuration – Release | Debug
- Special property
- Life expectancy on Mars. (Really? No, just kidding)
- Keep the history of all my builds
- Easily edit/clear the history
- Manageable text file
Fill It | Shut It | Forget It
(If you are not from India or below 25, you might not get this title. And it does not make any difference)
- Easy to setup
- Easy control
- Bare, no frill code
Ok, enough of all this requirement overload. Show me the code.