Click here to Skip to main content
Licence CPOL
First Posted 15 Feb 2008
Views 61,220
Downloads 0
Bookmarked 61 times

Solution level Auto build increment Add-In

By | 13 Jun 2008 | Article
Auto build version increment addin for Visual Studio 2005 and 2008

Update

  • 14 Jun 2008
    1. Now both or any of two, AssemblyVersion & AssemblyFileVersion can be updated.
    2. Fixed an error where options window doesn't comes up if project contains a setup or any other unsupported project type.
    3. Source control support added. Fix by S. Brozius.
  • 19 Feb 2008
    1. Support for Solution Folders added.
    2. Fixed a error where instead of updating the attribute, the add-in was updating the comment which is auto added by VS just before the actual attribute.

Introduction

In Visual Studio 2005 or 2008, there is no option for auto incrementing the build numbers on every build. Although many tools exist which enable us to do so, but I do not find them appealing or for daily/frequent use because of many reasons:

  1. Most tools update assembly version on a project level, i.e. you add pre-build or post-build event command lines to a project which call the tool and the tool updates the assembly version number. In such tools, you have to add such events every time you make a project and you cannot make templates for all project types, can you? You also need to specify project path, solution path or AssemblyInfo's path for every project.

  2. Most tools update assembly version based on the solution/project build date. You copy the poject to a new location, your assembly version gets messed up!!

I said "most tools" because there are many tools for this job. I might not have come across one which allows the features my add-in have.

For both the above reasons, I wrote a Visual Studio add-in compatible with both 2005 and 2008. The add-in is compatible with all solutions with either of one or more C# or VB.Net projects or both language projects.

Download

The add-in can be installed by the vsi file which can be downloaded from above.

The add-in is installed in the add-in directory of the version of Visual Studio installed. If you have both 2005 and 2008, it will install in both locations, but it might be possible that the add-in is only added to the add-in directory of Visual Studio 2005. I do not know why it happens, but it does happens on some machines. If this happens, you only need to copy AutoBuildIncrement.dll and AutoBuildIncrement.Addin from the add-in directory of 2005 to that of 2008.

Features

After you install the add-in, whenever you build a project for the first time, a start date variable is added in the project file based on the project creation date. The assembly version is updated based on this variable at every pre build. This behaviour applies to all the solutions you open in the studio, whether new or old.

The auto build numbers are only generated for Revision and Build Number values. You will have to manually update the Major Version and Minor Version values.

Format

The format of the Revision value is:
(months) + (days with a minimum length of 2 with 0 as front padd-ing)

The format of the Build Number value is:
(current hour) + (current minutes)

Example: (C#)
[assembly: AssemblyVersion(1.0.218.1402)]
where the solution was last built after being started since 2 months and 18 days back and was built at 2:02 AM.

Changing the default Features

You can change the default settings of the add-in for any individual solution. Whenever you have a solution opened, you can see the Auto Build Increment Add-in Settings... option in the Tools menu:

Toolmenu.jpg


When you select this option, a dialog is shown where all the projects in their appropriate solution folders (if they exist, that is) are listed with properties for all the individual projects:

SettingsWindow.jpg

The settings are pretty self explantory.

  • Reset: Reset 'AssemblyInfo' file date after modification: If checked, the last modified date of AssemblyInfo is automatically set to its previous setting after the modifications. (default:true)
  • Start Date: The date on which the project was started on. (default:project creation date)
  • Path: A read only property for displaying full path name of the project. (default: project's full path)

  • Enable: Enable auto build version update for the project. (default:true)

References

Feedback

I will love to hear your comments on this add-in. I will also like to know any features and suggestions you people can make for the improvement of the add-in.

License

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

About the Author

Yogesh Jagota



India India

Member

My Blog

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralAutosynchronize the Publish Version PinmemberMember 80577995:52 20 Jul '11  
GeneralCannot download Pinmemberxeg120:34 26 May '11  
GeneralRe: Cannot download PinmemberRisath1:02 17 Apr '12  
GeneralCreate problm in VS2010 Pinmembersumit_harit20:52 18 Apr '11  
Generalversioning is not reflecting in my case.. do I miss some process in embeding ur tool PinmemberAnil.csir2:00 17 Feb '11  
Questioncan this work for VS2010 PinmemberTushar Bhatt22:22 9 Jun '10  
GeneralConvert VS build number to date and time PinmemberAndrusM21:13 27 Sep '09  
GeneralDoesn't always update PinmemberGary Wayne Smith8:17 14 Sep '09  
GeneralCannot install the add-in PinmemberCreF0:12 20 Mar '09  
GeneralRe: Cannot install the add-in PinmemberMember 199542314:32 8 Apr '09  
GeneralRe: Cannot install the add-in Pinmemberdavorin_zg10:06 24 Jun '09  
GeneralUnable to download file Pinmember_Hairy_2:09 15 Mar '09  
AnswerRe: Unable to download file Pinmember_Hairy_7:15 16 Mar '09  
QuestionWeird version numbers Pinmemberbjoer75122:21 14 Dec '08  
I installed this component, would be great to use. But I get weird results...
The current project is a VB.Net project in VS2008.
 
In my AssemblyInfo.vb I changed to:

 
When I compile a release, I don't get what I expected as version, but instead I get:
1.4.3271.18421
 
If I use
I get 1.4.0.0
 
If I use
I get 1.4.0.18421
 
Well, the revision number increases with every build - but I can't map this to hours/minutes in any easy way.
 
The settings in Auto Build... are:
General->Reset: False
General->Start Date: 2008-10-10 (I live in Sweden, the format is YYYY-MM-DD)
Update->AssemblyFileVersion: True
Update->AssemblyVersion: True
 
What's wrong with my setup?

AnswerRe: Weird version numbers Pinmemberbjoer75123:21 14 Dec '08  
GeneralRe: Weird version numbers PinmemberYogesh Jagota1:40 15 Dec '08  
GeneralNo settings menu entry Pinmembermmoore998:01 6 Dec '08  
GeneralRe: No settings menu entry PinmemberYogesh Jagota11:57 6 Dec '08  
GeneralRe: No settings menu entry Pinmembermmoore9919:49 6 Dec '08  
GeneralRe: No settings menu entry PinmemberYogesh Jagota22:36 6 Dec '08  
GeneralDifferent time zones... PinmemberAlexZP2:04 4 Dec '08  
GeneralRe: Different time zones... PinmemberYogesh Jagota11:54 6 Dec '08  
GeneralExcellent Plugin PinmemberBrandon Ayers8:43 3 Nov '08  
GeneralRe: Excellent Plugin PinmemberYogesh Jagota11:53 6 Dec '08  
General2 problems I had with this tool PinmemberEuGenius_Krivbass23:57 22 Oct '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web02 | 2.5.120529.1 | Last Updated 14 Jun 2008
Article Copyright 2008 by Yogesh Jagota
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid