首頁  >  文章  >  後端開發  >  C# Asp.net Core中的Metapackage是什麼?

C# Asp.net Core中的Metapackage是什麼?

WBOY
WBOY轉載
2023-08-22 10:25:13925瀏覽

It is known that Microsoft.AspNetCore package is one of the packages added to many ASP.NET Core templates.

The Microsoft.AspNetCore package is repeatedly included as one of the usual project 在開啟一個新的ASP.NET Core專案時,它提供了許多依賴項 關鍵的軟體包以設定一個基本的ASP.NET Core應用程式。

儘管如此,軟體包不包含任何實際的dll或程式碼,它僅包含 a series of dependencies on additional packages. By adding this package to your project, you bring in all the relevant packages along with their dlls on which it depends and it is called a metapackage.

Specifically, the packages it lists are −

Microsoft.AspNetCore.Diagnostics
Microsoft.AspNetCore.Hosting
Microsoft.AspNetCore.Routing
Microsoft.AspNetCore.Server.IISIntegration
Microsoft.AspNetCore.Server.Kestrel
Microsoft.Extensions.Configuration.EnvironmentVariables
Microsoft.Extensions.Configuration.FileExtensions
Microsoft.Extensions.Configuration.Json
Microsoft.Extensions.Logging
Microsoft.Extensions.Logging.Console
Microsoft.Extensions.Options.ConfigurationExtensions
NETStandard.Library

The versions of these packages you will receive depends on which version of the Microsoft.AspNetCore package you install.

These dependencies deliver the primary basic libraries for setting up a basic ASP.NET Core伺服器使用Kestrel Web伺服器,並包含IIS整合。

就應用程式本身而言,僅使用此軟體包,您可以加載 將應用程式設定和環境變數轉換為配置,請使用IOptions interface,並配置日誌輸出到控制台。

對於中介軟體,只包括 Microsoft.AspNetCore.Diagnostics 套件 這將允許添加中間件,如ExceptionHandlerMiddleware,the 開發者異常頁面中間件(DeveloperExceptionPageMiddleware)和狀態碼頁面中間件(StatusCodePagesMiddleware)。

為了完成一個應用程序,我們不能只使用元包(Metapackage),因為它不 提供足夠的控制,但我們可以使用 Microsoft.AspNetCore.Mvc 或 Microsoft.AspNetCore.MvcCore package to add MVC capabilities to our application, and also some other packages would be needed.

The metapackage just try to use a number of packages that can be applied to many 應用程序,這樣我們就不需要加載更多的依賴項,但實際上並沒有這樣做 that because it requires other packages as well. Thus, if the number of packages is large then the dependencies increases which impacts the real use of metapackage. For example, one of the dependencies on which the Microsoft.AspNetCore depends is the NETStandard.Library package, which is also a metapackage and hence the 依賴關係增加。

以上是C# Asp.net Core中的Metapackage是什麼?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除