Difference between using the ASP.NET Core Web Application (.NET Core) with net461 set as the only framework and using the (.NET Framework) template
随着.NET Core RC2的发布,Microsoft推出了3个Web应用程序模板:
- ASP.NET Web应用程序(.NET框架)-旧的
- ASP.NET核心Web应用程序(.NET框架)-新的,仅在Windows上托管
- ASP.NET核心Web应用程序(.NET核心)-Linux、OSX、Windows
我正在尝试使用新的核心Web应用程序模板,但没有尝试以Linux、OSX、Windows为目标,因此,ASP.NET核心Web应用程序(.NET框架)似乎非常适合我。我花了一段时间,但我了解到要添加一个可用于此项目类型的类库,您需要添加一个类库(.net core),并将frameworks部分更改为only net461以匹配Web应用程序。
1 2 3 | "frameworks": { "net461": { } } |
我的问题:
创建ASP.NET核心Web应用程序(.NET核心)与在project.json中使net461成为唯一的目标框架有什么区别?
和
只是创建一个ASP.NET核心Web应用程序(.NET框架)项目,默认情况下该项目只包括Net461。
是否还有其他我不知道的区别,比如项目发布的方式等?
What is the difference between creating a ASP.NET Core Web Application
(.NET Core) and in project.json making.NET461 the only target
Framework
这和制作一个
just creating a ASP.NET Core Web Application (.NET Framework) project which only includes.NET461 by default.
Are there other difference that I am not aware of like the way the the projects are published, etc
If you target the .NET Framework and not .NET Core your app cannot be cross platform and your app can only run on Windows and not Linux/Mac.
存在单独的
前者没有
它还将影响编译,就好像您以
你可以通过调整你的
微软文档
You should use .NET Core for your server application when:
You have cross-platform needs.
You are targeting microservices.
You are using Docker containers.
You need high performance and scalable systems.
You need side by side of .NET versions by application.
You should use .NET Framework for your server application when:
- Your application currently uses .NET Framework (recommendation is to extend instead of migrating)
- You need to use third-party .NET libraries or NuGet packages not available for .NET Core.
- You need to use .NET technologies that are not available for .NET Core.
- You need to use a platform that doesn’t support .NET Core.
更新(2018/10/30)
已宣布2019年第一季度发布的
As announced on the .NET Blog earlier this month, .NET Framework will get fewer of the newer platform and language features that come to .NET Core moving forward, due to the in-place update nature of .NET Framework and the desire to limit changes there that might break existing applications. To ensure ASP.NET Core can fully leverage the improvements coming to .NET Core moving forward, ASP.NET Core will only run on .NET Core starting from 3.0. Moving forward, you can simply think of ASP.NET Core as being part of .NET Core.
Customers utilizing ASP.NET Core on .NET Framework today can continue to do so in a fully supported fashion using the 2.1 LTS release. Support and servicing for 2.1 will continue until at least August 21, 2021 (3 years after its declaration as an LTS release) in accordance with the .NET Support Policy.
首先,在针对不同框架创建ASP.NET核心Web应用程序时,可以看到project.json文件中的差异。
根据您的问题,如果您将ASP.NET核心Web应用程序(.NET核心)project.json中的框架更改为只有
如果删除microsoft.netcore.app依赖项并保存该文件,它将再次恢复依赖项,并且不会给出任何错误。
如果您注意到第一个图像,它最终将成为带有.NET框架的ASP.NET核心Web应用程序。
起初我也很困惑。主要区别在于ASP.NET Web应用程序(.NET框架)是我们一直使用的普通ASP.NET。它包含app_start folder web.config、global.asax等。(和MVC5一样,你明白了……)。
而ASP.NET核心Web应用程序(.NET框架)是核心框架(MVC6)。(不依赖System.Web)。全新项目。startup.cs和program.cs等…它还支持.NET框架的所有旧库。