5.1. Assembly Version NumberEvery assembly has a version number. That number applies to all components (potentially across multiple modules) in the assembly. You typically specify the version number in the Visual Studio 2005 project settings, although you can also assign a version number during the link phase, using command-line utilities and switches or MSBuild. To specify the version number using Visual Studio 2005, bring up the assembly properties, and open the Application tab. Click the Assembly Information button to display the Assembly Information dialog (see Figure 5-1). Figure 5-1. Specify the assembly version in the Assembly Information dialogNext to Assembly Version are four text boxes used to specify the assembly version. The Assembly Information dialog is merely a visual editor for a set of assembly attributes. These attributes are stored in the project's AssemblyInfo.cs file. The attribute used for the assembly version is AssemblyVersion. For example, the AssemblyVersion value corresponding to the settings in is: [assembly: AssemblyVersion("1.2.3.4")] The version number is recorded in the server assembly manifest. When a client developer adds a reference to the server assembly, the client assembly records in its manifest the name and the exact version of the server assembly against which it was compiled. If the client uses the class MyClass from version 1.2.3.4 of the assembly MyAssembly, the manifest of the client will record that the client requires version 1.2.3.4 of MyAssembly to operate and will contain this declaration: .assembly extern MyAssembly { .ver 1:2:3:4 } At runtime, .NET resolves the location of the requested assembly, and the client is guaranteed to get a compatible assembly. If a compatible assembly isn't found, an exception is thrown. The question is, what constitutes a compatible assembly? The rule of compatibility is straightforward: for a strongly named assembly (defined in the section "Strong Assembly Names"), a compatible assembly must have the exact same version number that the client's manifest requests. For a friendly named assembly, any assembly with the same friendly name is considered compatible. 5.1.1. Version Number ElementsThe version number is composed of four numbers: the major version number, minor version number, build number, and revision number. Figure 5-2 points out these numbers, in order. Figure 5-2. Breakdown of the assembly version numberAlthough you can assign any semantic to these numbers, there is a guideline or convention you should follow that conveys the meaning of version changes to the consumers of your assembly: a greater build number indicates a newer version of the same compatible assembly, and a greater revision number indicates some minor change (perhaps a minor bug fix) or changes made due to localization. As part of the product release procedures, you should verify that you have incremented the appropriate part of the version number, which reflects the nature of the new release.
5.1.2. Providing the Version NumberThe default version number provided by Visual Studio 2005 for new assemblies is 1.0.0.0. However, you can provide parts of the version number explicitly, or let Visual Studio 2005 generate them automatically. If you specify all four numbers explicitly, that will be the version number used. You can also provide * for the build and leave the revision number blank. This instructs the compiler to automatically generate build and revision numbers. For the build number, the compiler uses the number of days since January 1, 2000, local time. For the revision number, the compiler uses the number of seconds since midnight, local time, divided by two (without adjustment for daylight savings). A possible assembly version number generated by the compiler could be: 1.2.1642.18000 If you have some other schema for generating build numbers, you can use it and choose just to mask out the revision numbersimply specify the first three numbers manually and use a * for the revision number. The compiler then generates only the revision number, as just described.
|