Sdílet prostřednictvím


How to: Precompile ASP.NET Web Sites for Deployment

When you precompile an ASP.NET Web site for deployment you create a layout containing assemblies and other information that you can then copy to a production server. A Web site that is precompiled for deployment gives you the ability to create a compiled version of the site that can be deployed to a production server without source code.

You can choose to precompile either code and .aspx pages, or just the code. If you precompile only the code, you can update the user interface of the site without having to recompile the entire site.

The procedures in this topic use the switches and parameters of the ASP.NET Compilation Tool (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 precompile an ASP.NET Web site for deployment

  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, specifying the source as either a virtual path or physical path and the target folder for the compiled Web site.

    aspnet_compiler -v virtualPath targetPath
    

    If your Web site is not an Internet Information Services (IIS) application and therefore has no entry in the IIS metabase, used the following value for the -v switch.

    aspnet_compiler -p physicalOrRelativePath -v / targetPath
    

    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

To precompile an ASP.NET Web site for deployment and update

  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, specifying the source as either a virtual path or physical path, the target folder for the compiled Web site, and the -u switch indicating you want to compile the site for deployment and update.

    aspnet_compiler -p physicalOrRelativePath -v / targetPath -u
    

See Also

Tasks

How to: Precompile ASP.NET Web Sites

Other Resources

ASP.NET Web Site Precompilation