乘风破浪,遇见最佳跨平台跨终端框架.Net Core/.Net生态 - 官方扩展集锦(Microsoft.AspNetCore on Nuget)

2022/8/23 14:24:04

本文主要是介绍乘风破浪,遇见最佳跨平台跨终端框架.Net Core/.Net生态 - 官方扩展集锦(Microsoft.AspNetCore on Nuget),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

什么是Microsoft.AspNetCore

https://docs.microsoft.com/zh-cn/aspnet/core/fundamentals/metapackage-app

ASP.NET Core共享框架(Microsoft.AspNetCore.App)包含由Microsoft开发和支持的程序集。当安装NET Core 3.0或更高版本SDK时,安装Microsoft.AspNetCore.App。共享框架是安装在计算机上并包括运行时组件和目标包的一组程序集(.dll文件)。

  • 面向Microsoft.NET.Sdk.Web SDK的项目隐式引用Microsoft.AspNetCore.App框架。

对于这些项目,不需要其他引用:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>
    ...
</Project>

ASP.NET Core共享框架:

  • 不包括第三方依赖项。
  • 包括ASP.NET Core团队支持的所有包。

image

使用ASP.NET Core共享框架

随着.NET Core 3.0发布,许多ASP.NET Core程序集不再作为包发布到NuGet。而是改为将这些程序集包含在通过.NET Core SDK和运行时安装程序安装的Microsoft.AspNetCore.App共享框架中。若要查看不再发布的包列表,请参阅删除过时的包引用。

.NET Core 3.0起,使用Microsoft.NET.Sdk.Web MSBuild SDK的项目隐式引用此共享框架。使用Microsoft.NET.SdkMicrosoft.NET.Sdk.Razor SDK的项目必须引用ASP.NET Core,才能使用共享框架中的ASP.NET Core API。

若要引用ASP.NETCore,请将以下<FrameworkReference>元素添加到项目文件:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk.Razor">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>
    ...
</Project>

从ASP.NET Core 2.2升级到ASP.NET Core 3.0

不会为ASP.NET Core 3.0生成大量NuGet包。应从项目文件中删除此类包引用。

考虑以下适用于ASP.NET Core 2.2 Web应用的项目文件:

<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>

针对ASP.NET Core 3.0更新后的项目文件:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

</Project>

更新后的ASP.NET Core 3.0项目文件:

  • <PropertyGroup>中:
    • TFM更新为netcoreapp3.0
    • 删除了<AspNetCoreHostingModel>元素。
  • <ItemGroup>中:
    • 删除了Microsoft.AspNetCore.App
    • 删除了Microsoft.AspNetCore.Razor.Design

若要查看不再生成的包的完整列表,请选择以下展开列表:

  • Microsoft.AspNetCore
  • Microsoft.AspNetCore.All
  • Microsoft.AspNetCore.App
  • Microsoft.AspNetCore.Antiforgery
  • Microsoft.AspNetCore.Authentication
  • Microsoft.AspNetCore.Authentication.Abstractions
  • Microsoft.AspNetCore.Authentication.Cookies
  • Microsoft.AspNetCore.Authentication.Core
  • Microsoft.AspNetCore.Authentication.OAuth
  • Microsoft.AspNetCore.Authorization.Policy
  • Microsoft.AspNetCore.CookiePolicy
  • Microsoft.AspNetCore.Cors
  • Microsoft.AspNetCore.Diagnostics
  • Microsoft.AspNetCore.Diagnostics.HealthChecks
  • Microsoft.AspNetCore.HostFiltering
  • Microsoft.AspNetCore.Hosting
  • Microsoft.AspNetCore.Hosting.Abstractions
  • Microsoft.AspNetCore.Hosting.Server.Abstractions
  • Microsoft.AspNetCore.Http
  • Microsoft.AspNetCore.Http.Abstractions
  • Microsoft.AspNetCore.Http.Connections
  • Microsoft.AspNetCore.Http.Extensions
  • Microsoft.AspNetCore.HttpOverrides
  • Microsoft.AspNetCore.HttpsPolicy
  • Microsoft.AspNetCore.Identity
  • Microsoft.AspNetCore.Localization
  • Microsoft.AspNetCore.Localization.Routing
  • Microsoft.AspNetCore.Mvc
  • Microsoft.AspNetCore.Mvc.Abstractions
  • Microsoft.AspNetCore.Mvc.Analyzers
  • Microsoft.AspNetCore.Mvc.ApiExplorer
  • Microsoft.AspNetCore.Mvc.Api.Analyzers
  • Microsoft.AspNetCore.Mvc.Core
  • Microsoft.AspNetCore.Mvc.Cors
  • Microsoft.AspNetCore.Mvc.DataAnnotations
  • Microsoft.AspNetCore.Mvc.Formatters.Json
  • Microsoft.AspNetCore.Mvc.Formatters.Xml
  • Microsoft.AspNetCore.Mvc.Localization
  • Microsoft.AspNetCore.Mvc.Razor
  • Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
  • Microsoft.AspNetCore.Mvc.RazorPages
  • Microsoft.AspNetCore.Mvc.TagHelpers
  • Microsoft.AspNetCore.Mvc.ViewFeatures
  • Microsoft.AspNetCore.Razor
  • Microsoft.AspNetCore.Razor.Runtime
  • Microsoft.AspNetCore.Razor.Design
  • Microsoft.AspNetCore.ResponseCaching
  • Microsoft.AspNetCore.ResponseCaching.Abstractions
  • Microsoft.AspNetCore.ResponseCompression
  • Microsoft.AspNetCore.Rewrite
  • Microsoft.AspNetCore.Routing
  • Microsoft.AspNetCore.Routing.Abstractions
  • Microsoft.AspNetCore.Server.HttpSys
  • Microsoft.AspNetCore.Server.IIS
  • Microsoft.AspNetCore.Server.IISIntegration
  • Microsoft.AspNetCore.Server.Kestrel
  • Microsoft.AspNetCore.Server.Kestrel.Core
  • Microsoft.AspNetCore.Server.Kestrel.Https
  • Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions
  • Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets
  • Microsoft.AspNetCore.Session
  • Microsoft.AspNetCore.SignalR
  • Microsoft.AspNetCore.SignalR.Core
  • Microsoft.AspNetCore.StaticFiles
  • Microsoft.AspNetCore.WebSockets
  • Microsoft.AspNetCore.WebUtilities
  • Microsoft.Net.Http.Headers

Microsoft.AspNetCore Nuget包

集中组

名称 备注
Microsoft.AspNetCore >= .NET Standard 2.0;

Http组

名称 备注
Microsoft.AspNetCore.Http >= .NET Standard 2.0;
Microsoft.AspNetCore.Http.Features >= .NET 6.0;
>= .NET Standard 2.0;
>= .NET Framework 4.6.1;
Microsoft.AspNetCore.Http.Abstractions >= .NET Standard 2.0;
Microsoft.AspNetCore.Http.Extensions >= .NET Standard 2.0;
Microsoft.AspNetCore.Http.Connections.Common >= .NET 7.0;
>= .NET Standard 2.0;
>= .NET Framework 4.6.2;
Microsoft.AspNetCore.HttpOverrides >= .NET Standard 2.0;
Microsoft.AspNetCore.WebUtilities >= .NET Standard 2.0;

Hosting组

名称 备注
Microsoft.AspNetCore.Hosting >= .NET Standard 2.0;
Microsoft.AspNetCore.Hosting.Abstractions >= .NET Standard 2.0;
Microsoft.AspNetCore.Hosting.Server.Abstractions >= .NET Standard 2.0;
Microsoft.AspNetCore.Hosting.WindowsServices >= .NET 7.0;

Mvc组

名称 备注
Microsoft.AspNetCore.Mvc >= .NET Standard 2.0;
Microsoft.AspNetCore.Mvc.Core >= .NET Standard 2.0;
Microsoft.AspNetCore.Mvc.Abstractions >= .NET Standard 2.0;
Microsoft.AspNetCore.Mvc.Formatters.Json >= .NET Standard 2.0;
Microsoft.AspNetCore.Mvc.DataAnnotations >= .NET Standard 2.0;
Microsoft.AspNetCore.Mvc.ApiExplorer >= .NET Standard 2.0;
Microsoft.AspNetCore.Mvc.ViewFeatures >= .NET Standard 2.0;
Microsoft.AspNetCore.Mvc.NewtonsoftJson >= .NET 7.0;
Microsoft.AspNetCore.Mvc.Razor >= .NET Standard 2.0;
Microsoft.AspNetCore.Mvc.Razor.Extensions >= .NET Standard 2.0;
Microsoft.AspNetCore.Mvc.Localization >= .NET Standard 2.0;
Microsoft.AspNetCore.Mvc.TagHelpers >= .NET Standard 2.0;
Microsoft.AspNetCore.Mvc.Cors >= .NET Standard 2.0;
Microsoft.AspNetCore.Mvc.RazorPages >= .NET Standard 2.0;

Microsoft.System Nuget包

System组

名称 备注
System.Threading.Tasks.Extensions >= .NET Core 2.1;
>= .NET Standard 1.0;
>= .NET Framework 4.6.1;
System.Diagnostics.DiagnosticSource >= .NET 5.0;
>= .NETStandard 2.0;
>= .NETFramework 4.6.1;
System.Buffers >= .NET Core 2.0;
>= .NET Standard 1.1;
>= .NET Framework 4.5;
System.Memory >= .NET Core 2.1;
>= .NET Standard 1.1;
>= .NET Framework 4.6.1;

参考

  • Microsoft.AspNetCore in Nuget
  • 使用类库中的 ASP.NET Core API
  • Microsoft.AspNetCore.App for ASP.NET Core
  • Deep-dive into .NET Core primitives, part 2: the shared framework
  • 乘风破浪,遇见最佳跨平台跨终端框架.Net Core/.Net生态 - 官方扩展集锦(Microsoft.Extensions on Nuget)


这篇关于乘风破浪,遇见最佳跨平台跨终端框架.Net Core/.Net生态 - 官方扩展集锦(Microsoft.AspNetCore on Nuget)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程