Tuesday, March 02, 2010

How to Create Versioned Assemblies in the Visual Studio 2005 and Visual Studio 2008 Website

To create an assembly-information file for your website

  1. Using a text editor, create a new assembly-information file. For Visual Basic applications, the suggested file name is AssemblyInfo.vb. For C# applications, the suggested file name is AssemblyInfo.cs.

[assembly:System.Reflection.AssemblyVersionAttribute("versionNumber")]

Do not place the assembly-information file in the App_Code directory. If you place the assembly-information file in the App_Code directory, it will be compiled automatically by the ASP.NET runtime and might cause compilation errors later in the compilation process.

To specify the assembly-information file in your .aspx page

  1. Open your .aspx file in a text editor.
  2. Add the following attribute to the @ Page directive in the .aspx page.

CompilerOptions="path\AssemblyInfo.cs"

Replace the path parameter with the physical path to the assembly-information file on disk.

If the path to your assembly-information file contains spaces, you must enclose the path and file name in single quotation marks (').

CompilerOptions='"path with spaces\AssemblyInfo.cs"'

Replace the path with spaces parameter with the physical path to the assembly-information file on disk.

  1. Publish the website.

To specify the assembly-information file in your Web.config file

  1. Open your Web.config file in a text editor.
  2. Add the following code to your Web.config file.

"c#;cs;csharp" extension=".cs"

type="Microsoft.CSharp.CSharpCodeProvider, System,

Version=2.0.3600.0, Culture=neutral,

PublicKeyToken=b77a5c561934e089" warningLevel="1"

compilerOptions="path\AssemblyInfo.cs" />

  1. Publish the website

Ref: http://msdn.microsoft.com/en-us/library/ms228042.aspx

0 comments: