You have seen a file named "AssemblyInfo.cs (or .vb according to your programming language)" in your projects. This file contains information about the output assembly of your project such as Author's Name, Copyright Notice, ... and Assembly Version. By default assembly version is set to 1.0.0.0. This version declaration shows major.minor.build.revision numbers of your assembly. Two first numbers are commonly constant e.g. 2.0. Third number follows YYMMDD rule (of build date) and the last number is build counter.

It is a good idea to change assembly version and use it in your application. For example you can show Application Version to the end user. It's so easy, take a look:

Assembly assembly = Assembly.GetExecutingAssembly();
string
version = assembly.GetName().Version.ToString();

 But one thing that I was interested in was "How to tell Visual Studio 2005 change assembly version in an auto increment behavior?"

After I googled this issue I found a solution on MSBuild Team Blog. They built an AssemblyInfoTask on GotDotNet.com. It's so easy to be integrated in your project. Just download the required package and run it. It will install AssemblyInfoTask in your GAC or Application Data folder (depending on your choice). Then you should add this single line of code to your project file after last <Import> tag:

<Import Project="$(MSBuildExtensionsPath)\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.targets"/>

or this one (if you installed it in Data Application folder):

<Import Project="$(APPDATA)\Microsoft\MSBuild\AssemblyInfoTask\Microsoft.VersionNumber.Targets"/>

Everything is done now! Your Assembly Version will change automatically based on the rules I said before.

Because Setup file and updated help file of this project are located on GotDotNet.com and you should login to this site and also join this project to download them, I uploaded Setup package and updated Help file for you. Find them below:

Downlod: Setup Package | Updated Help File



 


Tuesday, May 09, 2006 5:02:25 PM (Iran Standard Time, UTC+03:30)
You can also simply set the AssemblyVersion attribute to "x.y.*" or "x.y.z.*".
Tuesday, May 09, 2006 6:03:57 PM (Iran Standard Time, UTC+03:30)
After seconding what Soheil pointed, I should say that this isn't what I do. It's better if you do it manually in AssemblyInfo.cs because when you contribute a project on a server based compilation for a team, you need to update the version in some regular steps ;-)
Tuesday, May 09, 2006 10:17:41 PM (Iran Standard Time, UTC+03:30)
And never even think of auto incrementing version number of a strongly-named shared assembly.
Tuesday, May 15, 2007 5:25:40 PM (Iran Standard Time, UTC+03:30)
I think manual is the better approach.
Tuesday, May 15, 2007 5:26:16 PM (Iran Standard Time, UTC+03:30)
There must be a more elegant way to handle that.
Tuesday, May 15, 2007 5:26:50 PM (Iran Standard Time, UTC+03:30)
I can just wait and see how this turns out.
Comments are closed.