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

乘风破浪,遇见最佳跨平台跨终端框架.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文件)。

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

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

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项目文件:

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

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;

参考

标签:Core,AspNetCore,Microsoft,跨平台,Mvc,集锦,NET,Standard,Net
来源: https://www.cnblogs.com/taylorshi/p/16614760.html