SgDotNet
Singapore Professional .NET User Group -For Cool Developers

Assembly Versioning

rated by 0 users
Not Answered This post has 0 verified answers | 2 Replies | 0 Followers

Top 25 Contributor
354 Posts
Vector posted on 10-10-2004 8:06 PM
Pros and cons of assembly versioning and its importance in an automated build environment.

This thread will be a primer on how to do assembly versioning, good practices around it, and how can it be integrated with the automated build process.
There is no gene for the human spirit. Gattaca.

All Replies

Top 25 Contributor
354 Posts
 

I will not go into the details of why should assemblies be versioned as the advantage are obvious, however this post will outline the no-nonsense way to implement versioning in your assemblies today:


Prerequisites:

1. Before an assembly can be versioned, it has to be strong named.

 

How-to:

 

  1. Create a new class library project.
  2. Go to VS.NET command prompt, and go to the project folder.
  3. Type sn -k privatekeyFileName.snk (This will create a key pair for strong naming your assembly)
  4. Go to your project, open the AssemblyInfo.cs file, scroll down to the following tabs and set the AssemblyKeyFile name

         [assembly: AssemblyDelaySign(false)]

         [assembly: AssemblyKeyFile("..\\..\\privatekeyFileName.snk")]

         [assembly: AssemblyKeyName("")]

 

  1. In AssemblyInfo.cs, go to following key and set the version of the assembly

         [assembly: AssemblyVersion("1.0.0.0")]

  1. Build the project. You have a versioned strong-named assembly.

 

 

Post-build: Caution

     1. A strong-named assembly may be installed in the global assembly cache as it is the only storage system currently which support version-aware storage. If you try to copy a new version assembly into a folder where an older version exists, you will have to overwrite the old file as normal windows folders do not support versioning.

  1. To install the assembly in GAC, Open VS.NET command prompt, go to project's bin folder, and type gacutil -I assemblyname.dll
  2. After many versions have been installed, to check which of them are in gacutil, type gacutil -l assemblyname

 

 

There is no gene for the human spirit. Gattaca.
Top 25 Contributor
354 Posts
This post explains how the runtime tries to locate a strong named assembly:

 

When u reference an assembly, during runtime the following process takes place to locate the assembly:

 

  1. Check the assembly manifest to find the version of the assembly that is referenced
  2. Check the app.config to see if it overrides the version in the manifest
  3. Check the publisher policy file in GAC to see if it overrides the app.config version and manifest
  4. Check the machine.config to see if it overrides the app.config, publisher policy file, and manifest.

 

Once the version has been determined, the assembly is searched in the following locations:

  1. Check in GAC
  2. Check in the location specified by the optional codebase element in app.config , which is overridden by publisher policy file which is in turn, overridden by machine.config
  3. Probe for the assembly given the type of reference of the assembly: if the culture is included

[application base] / [culture] / [assembly name].dll

[application base] / [culture] / [assembly name] / [assembly name].dll

  1. If culture is not included, it probes in

[application base] / [assembly name].dll

[application base] / [assembly name] / [assembly name].dll

 

  1. Lastly it also probes in the private bin path. If culture is defined,

[application base] / [binpath] / [culture] / [assembly name].dll

[application base] / [binpath] / [culture] / [assembly name] / [assembly name].dll

 

  1. If culture is not defined,

[application base] / [binpath] / [assembly name].dll

[application base] / [binpath] / [assembly name] / [assembly name].dll

There is no gene for the human spirit. Gattaca.
Page 1 of 1 (3 items) | RSS
Copyright SgDotNet 2004-2009
Powered by Community Server (Commercial Edition), by Telligent Systems