Click here to Skip to main content
Licence CPOL
First Posted 13 Feb 2007
Views 17,982
Downloads 388
Bookmarked 8 times

Updating the Assembly Version

By | 13 Feb 2007 | Article
Code and example showing how to update the Assembly Version.

Introduction

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("1.0.0.3")]
[assembly: AssemblyFileVersion("1.0.0.3")]

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"

License

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

About the Author

Aaron Sulwer

Web Developer

United States United States

Member

I have been coding for a couple of years now, i know i have a lot to learn but that takes time. ask me anything and i will try to help you!

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 2 PinmemberMoKa.LDS5:26 22 Sep '10  
GeneralEdit AssemblyInfo.cs PinmemberMoKa.LDS5:15 22 Sep '10  
GeneralMy vote of 2 PinmemberMember 43359331:29 3 Jul '09  
GeneralGood Thought! Pinmemberh52016:51 13 Feb '07  

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.120517.1 | Last Updated 13 Feb 2007
Article Copyright 2007 by Aaron Sulwer
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid