Click here to Skip to main content
14,304,866 members

Updating the Assembly Version

Rate this:
1.20 (12 votes)
Please Sign up or sign in to vote.
1.20 (12 votes)
13 Feb 2007CPOL
Code and example showing how to update the Assembly Version.


There really isn't really anything available that shows how to change the Assembly Version of an application every time it's built successfully, so I created one.

Now, the code for actually updating the Assembly Version isn't very elegant (!!!Please help me make this code better!!!). Basically, there is a pre-build event that calls either a batch file with the commands in it, or the commands are placed directly in the pre-build event of the application properties. In the test app that I have provided, I have the commands directly placed in the pre-build event, but in the real world, I have the commands in a batch file. I have placed a text file with appropriate changes if you would rather use the batch file method.

Basically, UpdateAssemblyVersion changes these two lines in the AssemblyInfo.cs file. When you compile your app and based on the switches you have included, your file's version numbers are changed. When you look at your complied application's properties, you can see what version it is (right click on the exe and choose Properties).

[assembly: AssemblyVersion("")]
[assembly: AssemblyFileVersion("")]

UpdateAssemblyVersion takes two to five command line arguments (one or more from the four below are required):

  • M: major
  • m: minor
  • -b: build
  • r: revision

These two lines are required. -f followed by the location of the file to change. The file must have the AssemblyVersion and AssemblyFileVersion in it.

-f "AssemblyInfo.cs"


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


About the Author

Aaron Sulwer
Software Developer (Senior)
United States United States
Been awhile since i have updated my CodeProject profile! My first programming language was c++. i have come along way since those days. Now c# and vb. My interests are cryptography and its related fields.

Comments and Discussions

GeneralMy vote of 2 Pin
MoKa.LDS22-Sep-10 5:26
professionalMoKa.LDS22-Sep-10 5:26 
GeneralEdit AssemblyInfo.cs Pin
MoKa.LDS22-Sep-10 5:15
professionalMoKa.LDS22-Sep-10 5:15 
GeneralRe: Edit AssemblyInfo.cs Pin
Aaron Sulwer14-Feb-14 6:25
memberAaron Sulwer14-Feb-14 6:25 
GeneralMy vote of 2 Pin
Member 43359333-Jul-09 1:29
memberMember 43359333-Jul-09 1:29 
GeneralRe: My vote of 2 Pin
Aaron Sulwer14-Feb-14 6:26
memberAaron Sulwer14-Feb-14 6:26 
GeneralGood Thought! Pin
h52013-Feb-07 16:51
memberh52013-Feb-07 16:51 

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.

Posted 13 Feb 2007


8 bookmarked