Export (0) Print
Expand All

How to: Precompile ASP.NET Web Site Projects for Deployment

When you precompile an ASP.NET Web site project for deployment you create a layout containing assemblies and other information that you can then copy to a production server. A Web site project that is precompiled for deployment gives you the ability to deploy the site to a production server and not have to deploy source code.

You can choose to precompile either code and pages and user controls (.aspx, .ascx, or .master files) 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 ASP.NET Precompilation Overview.

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, use the following command.

    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
    

Community Additions

Show:
© 2014 Microsoft