Click here to Skip to main content
Licence CPOL
First Posted 9 Jun 2006
Views 26,962
Bookmarked 9 times

Versioner: An AssemblyInfo version incrementer

By | 9 Jun 2006 | Article
A simple C# program that will increment the AssemblyVersion attribute of an AssemblyInfo.cs file.

Introduction

AssemblyVersion attributes of AssemblyInfo.cs files look something like these:

[assembly: System.Reflection.AssemblyVersion("1.0.0.0")]
[assembly: System.Reflection.AssemblyVersion("1.0.0.*")]
[assembly: System.Reflection.AssemblyVersion("1.0.*.*")]

The asterisks in the second and third examples will cause the compiler to set those two fields, but the values used may not be very useful. If you want useful values, you need to use the first example and set them yourself, but that can be a bit tedious.

This little program of mine will find an AssemblyVersion attribute in the specified file (if one exists) and attempt to increment its fourth field by one. You will still need to set the other fields manually, but that's just the nature of the beast.

Using the code

Compile Versioner.cs with your choice of C# compiler.

To run it, use:

Versioner AssemblyInfo.cs

Such a command may be added to a Visual Studio project as a "Pre-build event", this will cause the version to be incremented automatically when the project gets built.

History

  • First uploaded - 2006/06/09.

License

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

About the Author

PIEBALDconsult

Software Developer (Senior)

United States United States

Member

BSCS 1992 Wentworth Institute of Technology
 
Originally from the Boston (MA) area. Lived in SoCal for a while. Now in the Phoenix (AZ) area.
 
OpenVMS enthusiast, ISO 8601 evangelist, photographer, opinionated SOB
 
---------------
 
"Typing is no substitute for thinking." -- R.W. Hamming
 
"I find it appalling that you can become a programmer with less training than it takes to become a plumber." -- Bjarne Stroustrup
 
ZagNut’s Law: Arrogance is inversely proportional to ability.
 
"Well blow me sideways with a plastic marionette. I've just learned something new - and if I could award you a 100 for that post I would. Way to go you keyboard lovegod you." -- Pete O'Hanlon
 
"linq'ish" sounds like "inept" in German -- Andreas Gieriet
 

"Things would be different if I ran the zoo." -- Dr. Seuss
 
"Wrong is evil, and it must be defeated." – Jeff Ello
 
"A good designer must rely on experience, on precise, logical thinking, and on pedantic exactness." -- Nigel Shaw
 

"Omit needless local variables." -- Strunk... had he taught programming
 
"DON'T BE LIBERAL IN WHAT YOU ACCEPT!"
 
"Software Engineers don't have Trophy Wives; they have Presentation Layers."
 
"We learn more from our mistakes than we do from getting it right the first time."
 
"I'm an old dog and I like old tricks."
 
"Sometimes the envelope pushes back and sometimes you get a really nasty paper cut."
 
"A method shall have one and only one return statement."
 
My first rule of debugging: "If you get a different error message, you're making progress."
 
My golden rule of database management: "Do not unto others' databases as you would not have done unto yours."
 
My general rule of software development: "Design should be top-down, but implementation should be bottom-up."
 
"Today's heresy is tomorrow's dogma."
or
"Today's dogma is yesterday's heresy."
 
"The registry is evil."
 
"Every tool is a hammer."

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
GeneralMy vote of 5 Pinmemberjlabrou1:01 31 Aug '11  
GeneralChanging AssemblyInfo.cs does not work in VS 2008 PinmemberMember 14201063:06 11 Mar '08  
GeneralRe: Changing AssemblyInfo.cs does not work in VS 2008 PinmemberPIEBALDconsult5:27 16 Mar '08  
QuestionWorksaver.... Pinmemberfelix at home20:45 12 Sep '06  
GeneralRe: Worksaver.... PinmemberPIEBALDconsult5:47 14 Sep '06  
GeneralDon't get it PinmemberDustin Metzgar10:21 9 Jun '06  
GeneralRe: Don't get it PinmemberPIEBALDconsult17:05 7 Jul '06  
GeneralGood idea PinmemberTommi G10:04 9 Jun '06  
As an idea this sounds good - haven't tried this yet though. Best would be if this could be run as a VStudio Add-In - although I understand that then this won't work with other IDEs. Anyway, I loved the way VB6 worked with version info (autoincrement every build). Suggestions : make it possible only to increment each version's build number with this tool.
GeneralRe: Good idea PinmemberM.Lansdaal10:31 9 Jun '06  
GeneralRe: Good idea PinmemberPIEBALDconsult17:08 7 Jul '06  
GeneralRe: Good idea PinmemberPIEBALDconsult17:07 7 Jul '06  

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
Web01 | 2.5.120529.1 | Last Updated 9 Jun 2006
Article Copyright 2006 by PIEBALDconsult
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid