다음을 통해 공유


How to: Generate Fixed Names with the ASP.NET Compilation Tool

The ASP.NET Compilation Tool (Aspnet_compiler.exe) uses assembly names that are generated at compile time and are regenerated with each subsequent compilation. These generated assembly names work well with Web sites that are deployed as a whole; they are not well suited to Web sites that need to release updates to specific portions of the Web site without redeploying the entire Web site.

You can use the -fixednames switch for the ASP.NET Compilation Tool to generate fixed-assembly names. When you use the -fixednames switch, the ASP.NET Compilation Tool will do the following:

  • Create an assembly for each .aspx page in the application. You should limit the number pages in your application to reduce the number of assemblies that are generated.

  • Use the virtual path to the page as the name of the page's assembly. If the length of the virtual path exceeds the file-name length limit of the operating system, the tool uses a hash of the virtual path instead.

  • Compile the files in top-level directories, such as the App_Code directory, into a single assembly (like default compilation).

The procedure in this topic uses the switches and parameters of Aspnet_compiler.exe. For more information about this tool, see ASP.NET Compilation Tool (Aspnet_compiler.exe).

For more information about precompilation, see How to: Precompile ASP.NET Web Sites.

To compile a Web site with fixed-assembly names

  1. Open a command window and navigate to the folder containing the .NET Framework.

    The .NET Framework is installed in the following location.

    %windir%\Microsoft.NET\Framework\version
    
  2. Run the aspnet_compiler command by typing the following at a command prompt.

    aspnet_compiler -v virtualPath targetPath -fixednames
    

    The virtualPath parameter indicates the Internet Information Services (IIS) virtual path of your Web site. The targetPath parameter is a physical path to the destination directory.

    If your Web site is not an IIS application, and therefore has no entry in the IIS metabase, type the following at a command prompt.

    aspnet_compiler -p physicalOrRelativePath -v / targetPath -fixedNames
    

    In this case, the physicalOrRelativePath parameter refers to the fully qualified directory path in which the Web site files are located, or a path relative to the current directory. The period (.) operator is allowed in the physicalOrRelativePath parameter. The -v switch specifies a root that the compiler will use to resolve application-root references (for example, with the tilde (~) operator). When you specify the value of / for the -v switch, the compiler will resolve the paths using the physical path as the root.

    The targetPath parameter is a physical path to the destination directory.

See Also

Tasks

How to: Precompile ASP.NET Web Sites for Deployment

Other Resources

ASP.NET Web Site Precompilation