[04] ASP.NET Core Web project file

ASP.NET Core Web project file

Author: Liang Tongming - Microsoft Most Valuable Professionals (Microsoft MVP) 
article will be updated with the release, I get concerned about the latest version of 
this article comes from "scratch learning ASP.NET Core and EntityFramework Core" directory 
Better Video Course effects: cross platform development and combat to master ASP.NET Core EntityFramework Core 

ASP.NET Core Web project file

In this video, we will explore and learn asp.net core project file. We use C # as the programming language, so the project has a .csproj file extension.

If you've used previous versions of ASP.NET, you may be very familiar with this document, but the great changes the format and content contained in this document took place in asp.ne Core in.

One important change is that the project file does not contain any folder or file references.

After a brief explanation meaning. In previous ASP.NET, when we use the Solution Explorer to add files or folders to the project, the project file will contain the file or folder references. But in ASP.NET Core, the project file does not contain any folder or file references.

By the file system to determine which files and folders belong to the project. Part of all documents and files exist in the root directory of the project folder belong to the project, it will be displayed in Solution Explorer. When you add a file or folder, the file or folder will become part of the project, it will be immediately displayed in Solution Explorer. Similarly, when you delete a file in any file in the solution folder or folder, the deleted files or folders are no longer part of the project, will not show up immediately from the Solution Explorer.

In addition we work with project file has changed. In previous versions of asp.net, in order to be able to edit the project file, we first have to uninstall the program, edit and save the project file and then load the project again. In asp.net core, we can edit the project file without having to uninstall the program.

In the solution, right-click the project name and select "Edit StudentManagement.csproj" file.

4 1

This will open the .csproj file in the editor.

<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp2.2</TargetFramework> <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.AspNetCore.App" /> <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" /> </ItemGroup> </Project> 
C#

TargetFramework: As the name suggests, this element is used to specify the target frame application that you want to APId assembly provides for the application. To specify a target frame, we use a thing called Target Framework Moniker (TFM) is. As you can see in the above example, our application for TargetFramework value netcoreapp2.2. netcoreapp2.2 is .NET Core 2.2 of Moniker. When we created this application, we create a new project from the list, select the ** NET Core 2.2 ** as the target framework drop-down.

AspNetCoreHostingModel: This element specifies how the application should be hosted Asp.Net Core. It indicates that the program should be hosted InProcess (in-process) or OutOfProcess (out of process). InProcess specify the value of in-process we want to use hosted model, which hosted our asp.net core application in IIS worker process (w3wp.exe) in. OutOfProcess specify the value of the process we want to use an external hosting model, it will forward the request to the backend Web applications running ASP.NET Core Kestrel server.

We will discuss InProcess (in-process) and OutOfProcess (out of process) hosted in detail in the upcoming release of the video.

PackageReference: As the name suggests, this element is used to contain your application installation package for all NuGet references. In the project file, we have the following two NuGet package.

Microsoft.AspNetCore.App
Microsoft.AspNetCore.Razor.Design

Microsoft.AspNetCore.App: This NuGet package called metapackage. metapackage itself is no content, it only contains information dependent on other packages. You can find this metadata package in Solution Explorer in NuGet, while another is located in the NuGet ** dependency (Dependencies) **. When you expand the metadata package, you can find all the dependencies.

4 2

Microsoft.AspNetCore.App which contains ASP.NET Core 2.2 and later, and all the components of Entity Framework Core 2.2 and later.

In ASP.NET Core 2.1 and later default project template, we will always use this package.

Please note, metapackage is no version number. When not specify a version, SDK will implicitly specified version. .NET Core Team recommended that rely implicitly specified version of the SDK, instead of references explicitly set the version number in the package. If it is not entirely clear, please do not worry.

We will discuss in detail metapackage and implicit version in the upcoming release of the video.

Microsoft.AspNetCore.Razor.Design: This package contains the MSBuild support for Razor by Microsoft.AspNetCore.App of metapackage package references.

Summary

In this article, I try to explain to generate the project files in ASP.NET Core, as well as commonly used label elements inside. I hope this article can help you meet your needs. I would like to receive your feedback. Please post your feedback, questions or comments on this article.

 

Guess you like

Origin www.cnblogs.com/wer-ltm/p/11028215.html