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共享框架:
随着.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.Sdk
或Microsoft.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 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 | >= .NET Standard 2.0; |
名称 | 备注 |
---|---|
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; |
名称 | 备注 |
---|---|
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; |
名称 | 备注 |
---|---|
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; |
名称 | 备注 |
---|---|
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; |