ASP.NET Core - Project Structure

Here, you will learn about the project structure and significance of each file created by ASP.NET Core 2.0 application template using Visual Studio 2017.

The following is a default project structure when you create an empty ASP.NET Core application in Visual Studio.

ASP.NET Core Project Structure

The above solution explorer displays project solution. We can change it to folder view by clicking Solution and Folders icon and selecting Folder View option. This displays the solution explorer with all project folders and files as shown below.

Solution Explorer - Folder View
Note:
ASP.NET Core project files and folders are synchronized with physical files and folders. If you add a new file or folder in project folder then it will directly reflect in the solution explorer. You don't need to add it in the project explicitly by right clicking on the project.

.csproj

ASP.NET Core 1.0 does not create .csproj file, instead, it uses .xproj and project.json files to manage the project. This has changed in ASP.NET Core 2.0. Visual Studio now uses .csproj file to manage projects. We can edit the .csproj settings by right clicking on the project and selecting Edit <project-name>.csproj as shown below.

Edit .csproj

The .csproj for the above project looks like below.

Edit .csproj

The csproj file includes settings related to targeted .NET Frameworks, project folders, NuGet package references etc.

Dependencies

The Dependencies in the ASP.NET Core 2.1 project contain all the installed server-side NuGet packages, as shown below.

Dependencies

Right click on "Dependencies" and then click "Manage NuGet Packages.." to see the installed NuGet packages, as shown below.

Dependencies

As you can see, it has installed three packages, Microsoft.AspNetCore.App package is for ASP.NET web application, Microsoft.AspNetCore.Razor.Design package is for Razor engine, and Microsoft.NETCore.App package is for .NET Core API.

You can install all other required server side dependencies as NuGet packages from Manage NuGte Packages window or using Package Manager Console.

Properties

The Properties node includes launchSettings.json file which includes Visual Studio profiles of debug settings. The following is a default launchSettings.json file.

launchSettings.json

We can also edit settings from the debug tab of project properties. Right click on the project -> select Properties -> click Debug tab.

Project Properties

In the debug tab, select a profile which you want to edit as shown above. You may change environment variables, url etc.

Learn about wwwroot in the next chapter.

Want to check how much you know ASP.NET Core?