简体   繁体   English

什么<FrameworkReference Include="Microsoft.AspNetCore.App" />实际上是在 .net core 3+ 中做的吗?

[英]What <FrameworkReference Include="Microsoft.AspNetCore.App" /> is actually do in .net core 3+?

Recently, I've read about Use the ASP.NET Core shared framework and I'm wondering:最近,我阅读了有关使用 ASP.NET Core 共享框架的文章,我想知道:

  1. How is it working under the hood?它是如何在引擎盖下工作的?
  2. Are there any drawbacks or caveats that I should take into account when adding <FrameworkReference Include="Microsoft.AspNetCore.App" /> ?添加<FrameworkReference Include="Microsoft.AspNetCore.App" />时,我应该考虑任何缺点或注意事项吗?

For example, I'd created a simple console application and published it with self-hosted options.例如,我创建了一个简单的控制台应用程序并使用self-hosted选项发布它。 The output size was on 20mb greater with <FrameworkReference Include="Microsoft.AspNetCore.App" / even If I don't explicitly use any of Microsoft.AspNetCore packages <FrameworkReference Include="Microsoft.AspNetCore.App" /的输出大小增加了 20mb <FrameworkReference Include="Microsoft.AspNetCore.App" /即使我没有明确使用任何Microsoft.AspNetCore

The shared framework is a collection of assemblies that is included in the runtime and as such does not need to be resolved individually through NuGet.共享框架是包含在运行时中的程序集集合,因此不需要通过 NuGet 单独解析。 You can think of it as a NuGet package though, because the handling is very similar.不过,您可以将其视为 NuGet 包,因为处理方式非常相似。 The primary difference of course is that it doesn't need to be downloaded from NuGet because it is available locally with the runtime.当然,主要区别在于它不需要从 NuGet 下载,因为它可以在本地随运行时一起使用。

Since it is distributed with the runtime, that also means that you cannot reference a specific version of it.由于它与运行时一起分发,这也意味着您不能引用它的特定版本。 Instead, you always get the version that is included in the available version of the runtime.相反,您始终会获得包含在可用运行时版本中的版本。 This has the benefit that the contents will automatically update when the runtime is updated, so your application that depends on one of the shared frameworks will also just roll forward at runtime.这样做的好处是内容将在运行时更新时自动更新,因此依赖于共享框架之一的应用程序也将在运行时前滚。

  1. Attempting to answer that in detail is out of the scope of a Stack Overflow answer since this is some deep MSBuild logic.试图详细回答这个问题超出了 Stack Overflow 答案的范围,因为这是一些深层的 MSBuild 逻辑。 If you are interested to find out, you can checkout the dotnet/sdk repo though which contains everything that makes the Microsoft.NET.Sdk project SDK and its subtypes work, including the FrameworkReference implementation.如果您有兴趣了解,可以查看dotnet/sdk 存储库,其中包含使Microsoft.NET.Sdk项目 SDK 及其子类型正常工作的所有内容,包括FrameworkReference实现。

  2. First of all you should know that there is no way to use eg ASP.NET Core without using that framework reference.首先,您应该知道,如果不使用该框架参考,就无法使用例如 ASP.NET Core。 So it's not like you have much of a choice.所以你的选择并不多。 Most of the time, you won't be adding the framework reference yourself though;大多数情况下,您不会自己添加框架引用; ASP.NET Core applications use the Microsoft.NET.Sdk.Web project SDK which already includes the framework reference by default. ASP.NET Core 应用程序使用Microsoft.NET.Sdk.Web项目 SDK,其中默认已包含框架参考。 You will only need to add the framework reference yourself if you want to add ASP.NET Core references in a non-Web project (for example in a class library for ASP.NET Core).如果要在非 Web 项目中(例如在 ASP.NET Core 的类库中)添加 ASP.NET Core 引用,则只需自己添加框架引用。

    Apart from that, there aren't many things you will have to keep in mind though.除此之外,你需要记住的事情并不多。 Just remember not to use a version and keep your SDK and runtime updated to make sure that you have all the latest security patches.请记住不要使用某个版本并保持您的 SDK 和运行时更新,以确保您拥有所有最新的安全补丁。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NETSDK1073:无法识别 FrameworkReference 'Microsoft.AspNetCore.App' - NETSDK1073: The FrameworkReference 'Microsoft.AspNetCore.App' was not recognized 从 2.1 迁移到 3.1.Net Core,Microsoft.AspNetCore.App 的替代品是什么? - Migrating from 2.1 to 3.1 .Net Core, What is the Replacement of Microsoft.AspNetCore.App? 控制台应用程序已更新为 .Net Core 3.1 错误找不到框架“Microsoft.AspNetCore.App”,版本“3.1.0” - Console App Updated to .Net Core 3.1 Error The framework 'Microsoft.AspNetCore.App', version '3.1.0' was not found 警告 NETSDK1080:面向 .NET Core 3.0 或更高版本时,不需要对 Microsoft.AspNetCore.App 的 PackageReference - warning NETSDK1080: A PackageReference to Microsoft.AspNetCore.App is not necessary when targeting .NET Core 3.0 or higher 安装了.Net Core最新的SDK,但未找到'Framework'Microsoft.AspNetCore.App',版本'2.1.0' - .Net Core lastest SDK installed but getting 'Framework 'Microsoft.AspNetCore.App', version '2.1.0' was not found 找不到指定版本的 Microsoft.NetCore.App 或 Microsoft.AspNetCore.App。 .net 6.0升级 - The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found. .net 6.0 upgrade PackageReference Microsoft.AspNetCore.App 从核心 2.2 到核心 3 和 3.1 的方式变化 - PackageReference Microsoft.AspNetCore.App change of manner from core 2.2 to core 3 & 3.1 Microsoft.AspNetCore.App - 版本控制/是否应该在非ASP.NET类库中引用? - Microsoft.AspNetCore.App - Versioning / Should it be referenced in non ASP.NET class libraries? Docker - 在构建时找不到框架 microsoft.AspNetCore.App,版本 &#39;3.1&#39;0 - Docker - The framework microsoft.AspNetCore.App, version '3.1'0 was not found on build 修复指定的框架&#39;Microsoft.AspNetCore.App&#39;版本&#39;2.1.1&#39; - Fixing The specified framework 'Microsoft.AspNetCore.App', version '2.1.1'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM