.Net Core 3.x与.Net Framework 4.7的兼容性 [英] .Net Core 3.x compatibility with .Net Framework 4.7

查看:574
本文介绍了.Net Core 3.x与.Net Framework 4.7的兼容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个针对.Net Core 3.0的Visual Studio Azure应用服务项目.当我将其部署到Azure时,如果没有指定堆栈,则堆栈最终会显示.Net V4.7.

I have a Visual Studio Azure App Service project that targets .Net Core 3.0. When I deploy it to Azure, without me specifying a Stack, the Stack ends up .Net V4.7.

这篇文章提出了类似的问题:

This post asks a similar question: https://social.msdn.microsoft.com/Forums/en-US/a4040bf9-2ba0-42c6-a242-87febf7a5e6d/select-net-core-22-as-technology-stack?forum=windowsazurewebsitespreview The answer says "The .NET Core SDK 32-bit binaries are normally included with Windows app services. Therefore, there is no need to explicitly select .NET Core as the version". In other words: As it is Windows, there is no need to specify a .Net Core target. The implication is that because it is Windows, it'll just work.

这篇文章也提出了类似的问题: Azure webapp:堆栈设置答案是在最初创建Web应用程序之后,就不再需要确定该应用程序是.NET Core应用程序,因为.NET Core位已经安装在底层工作程序上."这也意味着,因为它是Windows,所以可以正常工作.

This post also asks a similar question: Azure webapp: Stack settings The answer says "after initial web app creation, there isn’t a need to identify that an app is a .NET Core app anymore because the .NET Core bits are already installed on the underlying worker". The implication is also that because it is Windows, it'll just work.

两者似乎都与Microsoft参考相抵触: https://docs .microsoft.com/en-us/dotnet/standard/net-standard

Both seem to contradict this Microsoft reference: https://docs.microsoft.com/en-us/dotnet/standard/net-standard

因此,.Net Core 3.0与任何版本的.Net Framework不兼容.更正式地说,.Net Standard 2.1被并入.Net Core 3.0,但没有.Net框架版本.但是,在Azure中,我的App Service实际上可以工作.

According to that, .Net Core 3.0 is NOT compatible with .Net Framework of any version. More formally, .Net Standard 2.1 is incorporated in .Net Core 3.0 but NO .Net framework version. Yet, in Azure, my App Service actually works.

问题:之所以能够运行,是因为尽管我已将.Net Core 3.0指定为Visual Studio中的目标,但实际上我并未使用任何特定于.Net Core 3.0的代码,因此,我很幸运能奏效? (爱荷华州,如果我要做某些特定于.Net Core 3.0的事情,它会因为运行时堆栈不再支持它而中断吗?)

Question: Is the reason that it works because although I have specified .Net Core 3.0 as the target in Visual Studio, I'm not actually using any .Net Core 3.0-specific code and therefore, I've been lucky that it works? (IOW, if I were to do something .Net Core 3.0-specific, it would break because the runtime stack would no longer support it?)

推荐答案

之所以起作用,是因为Azure App Service与.NET Framework一起部署为Windows OS的一部分,并安装了.NET Core SDK和运行时.您可以创建一个基本的Windows应用服务计划,创建与该计划绑定的Web应用,然后在kudu控制台中运行dotnet --info.这与在本地Windows开发人员框中安装.NET Core SDK和运行时完全相同.此外,我们正在努力在Windows App Services上获得.NET 3.x SDK和运行时.如果需要这些二进制文件,则可以使用Azure Pipelines安装这些SDK.

The reason it works is because Azure App Service is deployed with .NET Framework as part of the Windows OS with .NET Core SDKs and runtimes installed. You can create a basic windows app service plan, create a web app tied to that plan and run dotnet --info inside the kudu console. It's exactly the same as installing .NET Core SDK and runtimes on your local Windows dev box. In addition, we are working to get the .NET 3.x SDKs and runtimes on Windows App Services. If you need those binaries, you can use Azure Pipelines to install those SDKs.

因此,您可以将stack选项视为指导检查,以使您知道应用程序服务上可用的框架而无需推送框架依赖项.例如,如果.NET Core 3.0可用,那么您可以推动.NET Core 3.0应用程序框架依赖于而不是独立的.如果不存在,那么您就知道要在哪个区域计划应用程序,因为该框架尚未推出,因此您必须将其发布为自包含文件.

Therefore, you can think of the stack option as a guidance check to let you know what frameworks are available on the app service without pushing framework dependencies. E.g., if .NET Core 3.0 is available then you can push a .NET Core 3.0 app framework dependent rather than self-contained. If it's not there, then you know for that region you're planning your app to be in, you'll have to publish as self-contained as the framework hasn't been rolled out yet.

您很幸运,因为 .NET Core部署于2019年第四季度开始.如果您的csproj定位到3.1,我敢打赌您不会那么幸运:)因为3.1已在2020年4月8日部署到美国中北部和西部2.

You've been lucky because .NET Core rollout started 2019 Q4. Had your csproj targeted 3.1, I'm willing to bet you wouldn't get quite so lucky :) as 3.1 has been deployed to North Central and West US 2 as 4/8/2020.

这篇关于.Net Core 3.x与.Net Framework 4.7的兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆