AspNetCore.Docs/aspnetcore/host-and-deploy/directory-structure.md

42 lines
3.4 KiB
Markdown
Raw Normal View History

2016-10-29 01:35:15 +08:00
---
2017-07-01 07:47:15 +08:00
title: ASP.NET Core directory structure
author: guardrex
description: See the directory structure of published ASP.NET Core applications.
2016-10-29 01:35:15 +08:00
manager: wpickett
2018-01-29 23:21:31 +08:00
ms.author: riande
ms.custom: mvc
2017-03-17 08:43:46 +08:00
ms.date: 03/15/2017
ms.prod: asp.net-core
2018-01-29 23:21:31 +08:00
ms.technology: aspnet
ms.topic: article
uid: host-and-deploy/directory-structure
2016-10-29 01:35:15 +08:00
---
2017-04-08 04:11:19 +08:00
# Directory structure of published ASP.NET Core apps
2016-10-29 01:35:15 +08:00
By [Luke Latham](https://github.com/guardrex)
2016-10-29 01:35:15 +08:00
In ASP.NET Core, the application directory, *publish*, is comprised of application files, config files, static assets, packages, and the runtime (for self-contained apps).
2016-10-29 01:35:15 +08:00
| App Type | Directory Structure |
| ------------------------------ | ------------------- |
| Framework-dependent Deployment | <ul><li>publish\*<ul><li>logs\* (if included in publishOptions)</li><li>refs\*</li><li>runtimes\*</li><li>Views\* (if included in publishOptions)</li><li>wwwroot\* (if included in publishOptions)</li><li>.dll files</li><li>myapp.deps.json</li><li>myapp.dll</li><li>myapp.pdb</li><li>myapp.PrecompiledViews.dll (if precompiling Razor Views)</li><li>myapp.PrecompiledViews.pdb (if precompiling Razor Views)</li><li>myapp.runtimeconfig.json</li><li>web.config (if included in publishOptions)</li></ul></li></ul> |
| Self-contained Deployment | <ul><li>publish\*<ul><li>logs\* (if included in publishOptions)</li><li>refs\*</li><li>Views\* (if included in publishOptions)</li><li>wwwroot\* (if included in publishOptions)</li><li>.dll files</li><li>myapp.deps.json</li><li>myapp.exe</li><li>myapp.pdb</li><li>myapp.PrecompiledViews.dll (if precompiling Razor Views)</li><li>myapp.PrecompiledViews.pdb (if precompiling Razor Views)</li><li>myapp.runtimeconfig.json</li><li>web.config (if included in publishOptions)</li></ul></li></ul> |
2016-10-29 01:35:15 +08:00
\* Indicates a directory
The contents of 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 in the deployment, its location serves as the server's physical path to the hosted application. The *wwwroot* directory, if present, only contains static assets. The *logs* directory may be included in the deployment by creating it in the project and adding the `<Target>` element shown below to your *.csproj* file or by physically creating the directory on the server.
```xml
<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')" />
2017-03-17 08:43:46 +08:00
</Target>
```
2016-10-29 01:35:15 +08:00
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. Note that folder creation may still fail if the worker process doesn't have write access to the target folder.
2017-03-17 08:43:46 +08:00
The deployment directory requires Read/Execute permissions, while the *Logs* directory requires Read/Write permissions. Additional directories where assets will be written require Read/Write permissions.