Click here to Skip to main content
13,591,625 members
Click here to Skip to main content
Add your own
alternative version


23 bookmarked
Posted 30 Mar 2009
Licenced CPOL

Auto-Increment Project Build Number (VS 2008 compatible)

, 30 Mar 2009
Rate this:
Please Sign up or sign in to vote.
Increase the build number of the project each time you compile


Recently, I've noticed many people looking for a build number incrementor that works with Visual Studio 2008. I was also one of those people. Hence, I dug up an old macro I used in VS 2005 (written by Bellerephon here) and started to debug it. What I figured out was actually quite simplistic.

Using the Code

Since the instructions are the same from the original article, I will simply quote the original author:

  • Download the code and extract it.
  • Open up Visual Studio, and from the Tools menu, select Macros->Macros IDE.
  • Under the MyMacros heading in the Macro Project Explorer, open EnvironmentEvents and copy the function from the corresponding file in the zip.
  • Repeat for the functions in Module1.vb in the Zip.

That's all, your project build number will now be automatically incremented.

Basically, VS 2008 generates a project with an extra comment line in AssemblyInfo.cs.

// [assembly: AssemblyVersion("1.0.*")]

The macro was not working since an exception was thrown each time the macro tried to extract the current build number. Without the comment removed, the value was "*" which did not parse correctly.

So, the only line I had to add to the macro was:

' CS in VS2008 also inserts a comment line, so remove that as well.
    AIText = AIText.Replace("// [assembly: AssemblyVersion(""1.0.*"")]", "")
Catch ex As Exception
End Try        

Points of Interest

All in all, the solution to the build number problem was really easy. Once again, I would like to thank Bellerephon for his original code.


  • March 30, 2009 - First version


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

No Biography provided

You may also be interested in...


Comments and Discussions

GeneralThis only works for C# & VB, not C++. Pin
ggianop7-Sep-09 16:51
memberggianop7-Sep-09 16:51 
Generalgood note Pin
Donsw3-May-09 11:43
memberDonsw3-May-09 11:43 
GeneralSystem.IO Pin
kingjotte29-Apr-09 4:58
memberkingjotte29-Apr-09 4:58 
GeneralRe: System.IO Pin
That Asian Guy2-May-09 11:37
memberThat Asian Guy2-May-09 11:37 
GeneralRe: System.IO Pin
kingjotte2-May-09 13:57
memberkingjotte2-May-09 13:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.180618.1 | Last Updated 31 Mar 2009
Article Copyright 2009 by That Asian Guy
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid