Friday, September 21, 2007

* Assembly Version vs Assembly File Version

.NET framework provides opportunity to set two different types of version numbers to each assembly.

Assembly Version : This is the version number used by framework during build and at runtime to locate,link and load the assemblies. When you add reference to any assembly in your project, it is this version number which gets embedded. At runtime, CLR looks for assembly with this version number to load. But remember this version is used along with name, public key token and culture information only if the assemblies are strong-named signed. If assemblies are not strong-named signed, only file names are used for loading.

Assembly File Version : This is the version number given to file as in file system. It is displayed by Windows Explorer. Its never used by .NET framework or runtime for referencing.

So, how do you best make use of these file numbers available. This is one way of using it, if you guys know a better way .. let me know.

Attributes in AssemblyInfo.cs

// Version information for an assembly consists of the following four values:
//      Major Version
//      Minor Version
//      Build Number
//      Revision
[assembly: AssemblyVersion("")]
[assembly: AssemblyFileVersion("")]

Providing a (*) in place of absolute number makes compiler increase the number by one every time you build.

Suppose you are building a framework assembly for your project which is used by lot of developers while building the application assemblies. If you release new version of assembly very frequently, say once every day, and if assemblies are strong named, Developers will have to change the reference every time you release new assembly. This can be quite cumbersome and may lead to wrong references also. A better option in such closed group and volatile scenarios would be to fix he 'Assembly Version' and change only the 'Assembly File Version'. Use the assembly file version number to communicate the latest release of assembly. In this case, developers will not have to change the references and they can simply overwrite the assembly in reference path. In central/final release builds in make more sense to change the 'Assembly Version' and most keep the 'Assembly File Version' same as assembly version.


  1. Thanks for this! I was just looking to set the assembly version and saw the assembly file version and didn't have a clue - but now I do. Thanks again!

  2. Thanks for great explanation, much appreciated.

  3. It doesn't increase it by one, but instead uses date/time. e.g. 1.2._date_._time_.

    _date_ is the number of days since 1/1/2000 and _time_ is number of seconds since midnight.