Redigera

Dela via


ASP.NET Core directory structure

Note

This isn't the latest version of this article. For the current release, see the .NET 8 version of this article.

Warning

This version of ASP.NET Core is no longer supported. For more information, see .NET and .NET Core Support Policy. For the current release, see the .NET 8 version of this article.

Important

This information relates to a pre-release product that may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

For the current release, see the .NET 8 version of this article.

The publish directory contains the app's deployable assets produced by the dotnet publish command. The directory contains:

App Type Directory Structure
Framework-dependent Executable (FDE)
  • publish†
    • Views† MVC apps; if views aren't precompiled
    • Pages† MVC or Razor Pages apps, if pages aren't precompiled
    • wwwroot†
    • *.dll files
    • {ASSEMBLY NAME}.deps.json
    • {ASSEMBLY NAME}.dll
    • {ASSEMBLY NAME}{.EXTENSION}.exe extension on Windows, no extension on macOS or Linux
    • {ASSEMBLY NAME}.pdb
    • {ASSEMBLY NAME}.runtimeconfig.json
    • web.config (IIS deployments)
    • createdump (Linux createdump utility)
    • *.so (Linux shared object library)
    • *.a (macOS archive)
    • *.dylib (macOS dynamic library)
Self-contained Deployment (SCD)
  • publish†
    • Views† MVC apps, if views aren't precompiled
    • Pages† MVC or Razor Pages apps, if pages aren't precompiled
    • wwwroot†
    • *.dll files
    • {ASSEMBLY NAME}.deps.json
    • {ASSEMBLY NAME}.dll
    • {ASSEMBLY NAME}{.EXTENSION} .exe extension on Windows, no extension on macOS or Linux
    • {ASSEMBLY NAME}.pdb
    • {ASSEMBLY NAME}.runtimeconfig.json
    • web.config (IIS deployments)

†Indicates a directory

The publish directory represents the content root path, also called the application base path, of the deployment. Whatever name is given to the publish directory of the deployed app on the server, its location serves as the server's physical path to the hosted app.

The wwwroot directory, if present, only contains static assets.

Additional resources

The publish directory contains the app's deployable assets produced by the dotnet publish command. The directory contains:

App Type Directory Structure
Framework-dependent Executable (FDE)
  • publish†
    • Views† MVC apps; if views aren't precompiled
    • Pages† MVC or Razor Pages apps, if pages aren't precompiled
    • wwwroot†
    • *.dll files
    • {ASSEMBLY NAME}.deps.json
    • {ASSEMBLY NAME}.dll
    • {ASSEMBLY NAME}{.EXTENSION}.exe extension on Windows, no extension on macOS or Linux
    • {ASSEMBLY NAME}.pdb
    • {ASSEMBLY NAME}.Views.dll
    • {ASSEMBLY NAME}.Views.pdb
    • {ASSEMBLY NAME}.runtimeconfig.json
    • web.config (IIS deployments)
    • createdump (Linux createdump utility)
    • *.so (Linux shared object library)
    • *.a (macOS archive)
    • *.dylib (macOS dynamic library)
Self-contained Deployment (SCD)
  • publish†
    • Views† MVC apps, if views aren't precompiled
    • Pages† MVC or Razor Pages apps, if pages aren't precompiled
    • wwwroot†
    • *.dll files
    • {ASSEMBLY NAME}.deps.json
    • {ASSEMBLY NAME}.dll
    • {ASSEMBLY NAME}{.EXTENSION} .exe extension on Windows, no extension on macOS or Linux
    • {ASSEMBLY NAME}.pdb
    • {ASSEMBLY NAME}.Views.dll
    • {ASSEMBLY NAME}.Views.pdb
    • {ASSEMBLY NAME}.runtimeconfig.json
    • web.config (IIS deployments)

†Indicates a directory

The publish directory represents the content root path, also called the application base path, of the deployment. Whatever name is given to the publish directory of the deployed app on the server, its location serves as the server's physical path to the hosted app.

The wwwroot directory, if present, only contains static assets.

Additional resources

The publish directory contains the app's deployable assets produced by the dotnet publish command. The directory contains:

App Type Directory Structure
Framework-dependent Executable (FDE)
  • publish†
    • Views† MVC apps; if views aren't precompiled
    • Pages† MVC or Razor Pages apps, if pages aren't precompiled
    • wwwroot†
    • *.dll files
    • {ASSEMBLY NAME}.deps.json
    • {ASSEMBLY NAME}.dll
    • {ASSEMBLY NAME}{.EXTENSION} .exe extension on Windows, no extension on macOS or Linux
    • {ASSEMBLY NAME}.pdb
    • {ASSEMBLY NAME}.Views.dll
    • {ASSEMBLY NAME}.Views.pdb
    • {ASSEMBLY NAME}.runtimeconfig.json
    • web.config (IIS deployments)
    • createdump (Linux createdump utility)
    • *.so (Linux shared object library)
    • *.a (macOS archive)
    • *.dylib (macOS dynamic library)
Self-contained Deployment (SCD)
  • publish†
    • Views† MVC apps, if views aren't precompiled
    • Pages† MVC or Razor Pages apps, if pages aren't precompiled
    • wwwroot†
    • *.dll files
    • {ASSEMBLY NAME}.deps.json
    • {ASSEMBLY NAME}.dll
    • {ASSEMBLY NAME}.exe
    • {ASSEMBLY NAME}.pdb
    • {ASSEMBLY NAME}.Views.dll
    • {ASSEMBLY NAME}.Views.pdb
    • {ASSEMBLY NAME}.runtimeconfig.json
    • web.config (IIS deployments)

†Indicates a directory

The publish directory represents the content root path, also called the application base path, of the deployment. Whatever name is given to the publish directory of the deployed app on the server, its location serves as the server's physical path to the hosted app.

The wwwroot directory, if present, only contains static assets.

Creating a Logs folder is useful for ASP.NET Core Module enhanced debug logging. Folders in the path provided to the <handlerSetting> value aren't created by the module automatically and should pre-exist in the deployment to allow the module to write the debug log.

A Logs directory can be created for the deployment using one of the following two approaches:

  • Add the following <Target> element to the project file:

    <Target Name="CreateLogsFolder" AfterTargets="Publish">
       <MakeDir Directories="$(PublishDir)Logs" 
                Condition="!Exists('$(PublishDir)Logs')" />
       <WriteLinesToFile File="$(PublishDir)Logs\.log" 
                         Lines="Generated file" 
                         Overwrite="True" 
                         Condition="!Exists('$(PublishDir)Logs\.log')" />
    </Target>
    

    The <MakeDir> element creates an empty Logs folder in the published output. The element uses the PublishDir property to determine the target location for creating the folder. Several deployment methods, such as Web Deploy, skip empty folders during deployment. The <WriteLinesToFile> element generates a file in the Logs folder, which guarantees deployment of the folder to the server. Folder creation using this approach fails if the worker process doesn't have write access to the target folder.

  • Physically create the Logs directory on the server in the deployment.

The deployment directory requires Read/Execute permissions. The Logs directory requires Read/Write permissions. Additional directories where files are written require Read/Write permissions.

Additional resources