Versioned Assemblies for Precompiled ASP.NET Web Sites
There's a good article about how to create versioned assemblies for precompiled ASP.NET web sites. You can read it here.
In order to create versioned assemblies, one of the easiest way is to add a compilerOptions attribute to the compiler Element in your web.config file. You will also have to create an assembly information file in your web application so that it can refer to the version information. In the assembly information file, you would have an attribute like the following:
[assembly:System.Reflection.AssemblyVersionAttribute("versionNumber")]
Please note that the each decimal point in the version number has to be an integer, and it has to be in the format of "major version"."minor version"."build number"."revision". This page has all the information about the format of the versionNumber parameter.
By following the conventional developer wisdom means you will hit F5, or Build the Website. Kaboom! An error appears, and it says:
Source file 'path\AssemblyInfo.cs' could not be found
You'd spend the next tens of minutes checking if your path is correct, or if the AssemblyInfo.cs file was spelt correctly. Do not fret. I'm telling you that you need not worry. The version information is not taken into account by the compilation procedure in Visual Studio. Instead, it is taken into account by the ASP.NET precompiler. You could precompiler your ASP.NET Web site using the following command (launch the Visual Studio 2008 Command Prompt):
aspnet_compiler -p physicalOrRelativePath -v / targetPath
This page describes everything you need to know about precompiling ASP.NET Web sites.
To ensure that your assembly was indeed "versioned":
- At the Visual Studio 2008 Command Prompt, navigate to the targetPath that you have specified in the aspnet_compiler command-line options.
- Go to the bin folder of your precompiled and deployed ASP.NET Web site.
- Run ildasm App_Code.dll.
- You will see the version information such as the following:
.assembly App_Code
{
.ver 1:1:2002:2
}
Hence if you want to have versioned assemblies, this should be a step after building (compiling) your ASP.NET Web site in Visual Studio. The precompilation will take care of the versioning of your assembly. If anyone know the proper way of doing this, please do leave a comment in this blog post.
Comments
- Anonymous
October 02, 2008
You've been kicked (a good thing) - Trackback from DotNetKicks.com