• Home
  • About
  • Contact
  • ado.net
  • angular
  • c#.net
  • design patterns
  • linq
  • mvc
  • .net core
    • .Net Core MVC
    • Blazor Tutorials
  • sql
  • web api
  • dotnet
    • SOLID Principles
    • Entity Framework
    • C#.NET Programs and Algorithms
  • Others
    • C# Interview Questions
    • SQL Server Questions
    • ASP.NET Questions
    • MVC Questions
    • Web API Questions
    • .Net Core Questions
    • Data Structures and Algorithms

Tuesday, August 18, 2020

ASP.NET Core Project File

 Admin     August 18, 2020     .Net, .Net Core, Asp.Net, C#     No comments   

In this article, I am going to discuss the ASP.NET Core Project File in detail. Please read our previous article before proceeding to this article, where we discussed how to create ASP.NET Core Web Application as well as we also discussed the different project templates that are available as part of ASP.NET Core Web Application.

If you worked with the previous versions of ASP.NET Framework, then you may know, if you are using C# as the programming language then the framework will create the project file with ”.csproj” as the extension. Similarly, if you are using VB as the programming language, then it will create the project file with “.vbproj” as the file extension. But with ASP.NET Core, the format and content of the project file have been changed significantly.

Changes in the Project file in ASP.NET Core Application:
The ASP.NET Core Project File does not contain any references for folder or file. In previous versions of ASP.NET Framework, when we add a folder or a file to the project using Solution Explorer, then a reference to that folder or file is added in the project file. But with ASP.NET Core, the Project File does not include any reference for the Files or Folders added the project using Solution Explorer.

Another significant change in ASP.NET Core is, the File System determines what folders and files belong to the project. Generally, the files and folders which are present at the project root folder are part of the project. Those files and folders which are present at the project root folder are only going to display in the Solution Explorer.

So, if you add a file or a folder using the File Explorer, then that file or folder is part of the project. As soon as you add a file or folder using the file explorer, it immediately displayed in the solution explorer. In the same way, if you delete a file or folder from the Project Folder or any of its subfolders, then that deleted file or folder is no longer part of the project and that is reflected immediately in the Solution Explorer.

How we can Edit the Project File in Previous Versions of ASP.NET:
In our previous versions of ASP.NET Framework, in order to edit the project file, we need to follow the following steps
  1. First, we need to unload the project
  2. Then we need to edit the project file
  3. Once we edit the file then we need to save the project file
  4. Then reload the project.
But with ASP.NET Core we can edit the project file without unloading the project.

How we can Edit the ASP.NET Core Project File:
To edit the ASP.NET Core project file, right-click on the project name in the Solution Explorer, and then select “Edit FirstCoreWebApplication.csproj” as shown in the below image.
How to Edit the ASP.NET Core Project File

Once you click on the “Edit FirstCoreWebApplication.csproj” then the file will open in the editor as shown below.
ASP.NET Core Project File Content

Understanding the ASP.NET Core Project File:
Let us understand the ASP.NET Core Project File elements.

TargetFramework:
The TargetFramework element in the project file is used to specify the target framework for your application. To specify the target framework in the project file we are using something called Target Framework Moniker (TFM).

In our example, the application targets the framework netcoreapp2.2. The netcoreapp2.2 is the Moniker for .NET Core 2.2. If you remember, while we are creating this project, we select .NET Core 2.2 as the target framework.

AspNetCoreHostingModel:
The AspNetCoreHostingModel element of the project file is used to specify how we are going to host the asp.net core application. Values for this AspNetCoreHostingModel element are either InProcess or OutOfProcess.

The value InProcess specifies that we are going to use the in-process hosting model for our application. It means we are going to host the ASP.NET Core Application inside of the IIS Worker Process which is nothing but w3wp.exe.

The value OutOfProcess specifies that we are going to use the out-of-process hosting model. In a later article, we will discuss the In Process and Out Of Process hosting model in detail.

PackageReference:
The Package Reference element of the project file is used to add the references to all the NuGet packages which are installed for your application. At the moment, the project file adds references for the following 2 NuGet packages.
  1. Microsoft.AspNetCore.App
  2. Microsoft.AspNetCore.Razor.Design
Let us discuss these two packages in detail.

Microsoft.AspNetCore.App:
Microsoft.AspNetCore.App NuGet package is generally called the Meta Package. The Meta Package has not any content of its own but it contains a list of dependencies i.e. it contains other packages.

You can find this Meta Package, in the Solution Explorer, under NuGet which is present inside the Dependencies. When you expand the Meta Package, then you will find all the dependencies as shown in the below image.
Microsoft.AspNetCore.App Meta Package

As you can see in the project file, there is no version number for the Meta Package. When the version for a package is not specified, then an implicit version is specified by the SDK. In our upcoming articles, we will discuss more regarding Meta Package and implicit version.

Microsoft.AspNetCore.Razor.Design:
Microsoft.AspNetCore.Razor.Design package contains MSBuild support for Razor. This is also referenced by Microsoft.AspNetCore.App Meta Package.

In the next article, I am going to discuss the Main method in the ASP.NET Core application. Here, in this article, I try to explain the ASP.NET Core Project File in detail. I hope you enjoy this article and I would like to have your feedback. Please post your feedback, question, or comments about this article.

Summary:
I hope this post will be helpful to understand the ASP.NET Core Project File
Please share this post with your friends and colleagues.
For any queries please post a comment below.
Happy Coding 😉
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Post Older Post

0 comments:

Post a Comment

If you like this website, please share with your friends on Facebook, Twitter, LinkedIn.

Join us on Telegram

Loved Our Blog Posts? Subscribe To Get Updates Directly To Your Inbox

Like us on Facebook

Popular Posts

  • What is Dependency Injection(DI)
    Hi friends! Today we are going to learn about Dependency Injection and in our last session we have come across Static classes and where it s...
  • C# Programming Examples on Sorting
    Today i am going to tell you some of the Sorting programming questions in C#. Q1- Write a C# program to perform Selection sort. Ans:  Sel...
  • Calling Web API Service in a Cross-Domain Using jQuery AJAX
    In this article, I am going to discuss Calling Web API Service in a Cross-Domain Using jQuery AJAX . Please read our previous article befor...
  • ViewBag in ASP.NET Core MVC
    In this article, I am going to discuss the use of ViewBag in ASP.NET Core MVC application with examples. Please read our previous article ...
  • Recursion And Back Tracking
    In this article, I am going to discuss Recursion And BackTracking in detail. Please read our previous article where we discussed Master Th...
  • What is Abstract Class and When we should use Abstract Class
    Hi friends! In our previous sessions we have seen  Difference Between Class and Struct . And in our last session  we learnt Usability of Sec...
  • Binary to Decimal Conversion in C# with Examples
    In this article, I am going to discuss the Binary to Decimal Conversion in C# with some examples. Please read our previous article where w...

Blog Archive

Contact Form

Name

Email *

Message *

Tags

.Net .Net Core .Net Core MVC Algorithm Angular Anonymous Types Asp.Net Asp.Net MVC Blazor C# Data Structure Database Design Patterns Entity Framework Entity Framework Core Filters Interview Question Management Studio Programming Programs SQL Server SSMS Web API

Copyright © C# Techtics | All Right Reserved.

Protected by Copyscape