7

How do I programmatically increment a given version's number to the next version of the highest one?

For example if I have a file Program.exe with the following version numbers :

Program.exe 1.0.0.0
Program.exe 1.0.0.4
Program.exe 1.1.0.76
Program.exe 1.0.0.66

The next version number in this case would be 1.1.0.77

What's the easiest way to implement that?

Thanks for any help in advance

0

4 Answers 4

6

Use a version control solution, like Subversion or git, and/or a build tool.

Certainly a version control solution will provide functionality to insert version information into the source code as it is committed via a magic string you include in your source like $Rev$, which you can then use as a build number.

Here's a blog post showing how it's done with Subversion.

2
  • CI Factory is a build tool with this capability.
    – AaronLS
    Jan 28, 2010 at 0:33
  • Thanks! I so just added that to my code(which uses Subversion)
    – Earlz
    Jan 28, 2010 at 0:53
2

If you're trying to do that to set the program properties (not just in the source code as Brabster suggested), you could set visual studio to automatically change the build number. The problem is that the number is not sequential. Check out this link to see how easy it can be done.


Also check this post.

1
  • The referenced post (second link) really contains all you need to know. Jan 28, 2010 at 0:43
1

If you want an auto incrementing number that updates each time a compilation is done, you can use VersionUpdater from a pre-build event. This has the advantage of more control than the default numbering mechanism described on MSDN.

Your pre-build event can check the build configuration if you prefer so that the version number will only increment for a Release build (for example).

0

I always use AssemblyInfo Task (http://code.msdn.microsoft.com/AssemblyInfoTaskvers). Though it does not support the feature you want, it is an easy way to manage version numbers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.