使用将net461设置为唯一框架的ASP.NET Core Web应用程序(.NET Core)与使用(.NET Framework)模板之间的区别 [英] Difference between using the ASP.NET Core Web Application (.NET Core) with net461 set as the only framework and using the (.NET Framework) template

查看:432
本文介绍了使用将net461设置为唯一框架的ASP.NET Core Web应用程序(.NET Core)与使用(.NET Framework)模板之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着.NET Core RC2的发布,Microsoft做到了,因此现在有3种Web应用程序模板:




  • ASP.NET Web应用程序(.NET Framework)-旧的

  • ASP.NET核心Web应用程序(.NET Framework)-新的,仅在Windows上托管

  • ASP.NET Core Web应用程序(.NET Core)-Linux,OSX,Windows



我正在尝试使用新的Core Web应用程序模板,但没有尝试针对Linux,OSX,Windows,因此ASP.NET Core Web应用程序(.NET Framework)似乎非常适合我。我花了一段时间,但我了解到,要添加一个适用于此项目类型的类库,您需要添加一个类库(.NET Core)并将Frameworks部分更改为net461以匹配Web应用程序。

 框架:{
net461:{}
}

我的问题:



什么是创建ASP.NET Core Web应用程序(.NET Core)和project.json之间的区别使net461成为唯一的目标框架





仅创建一个ASP.NET Core Web应用程序(.NET Framework)项目,默认情况下仅包含net461。



还有其他区别吗?我不知道项目的发布方式等。

解决方案


是创建ASP.NET Core Web应用程序
(.NET Core)和在project.json中的区别,使.NET461成为唯一arget
框架


这与制作 ASP.NET Core Web应用程序相同 code>( .NET Framework )项目。两者之间的项目类型由 .csproj 文件确定,而您在 .csproj 中将其更改为定位 .NET Core 定位到 .NET Framework 。在 ASP.NET Core 的早期发行版/测试版中,可能在 project.json 文件中同时包含两个框架。 (已被.NET开发人员所熟悉的.NET Core 2.0中的简化的 .csproj 文件所代替),但是您只能发布到其中一个。


仅创建一个ASP.NET Core Web应用程序(.NET Framework)项目,默认情况下仅包含.NET461。



还有其他我不知道的区别,例如项目的发布方式等吗?
如果您面向.NET Framework而不是.NET Core,则您的应用程序不能跨平​​台,并且该应用程序只能在Windows上运行,而不能在Linux / Mac上运行。


使用单独的 ASP.NET的原因Core Web应用程序( .NET Core )和 ASP.NET Core Web应用程序( .NET Framework )是因为后者允许您利用函数pack计算机上需要安装依赖于Windows且具有相同 .NET Framework 或更高版本的年龄或第三方库。



前者没有 .NET Framework 的要求,但允许您的应用程序是跨平台的,并且当您发布应用程序时,它会发布所有相关的<将code> .NET Core dll文件复制到发布目录,以避开 .NET Framework 的安装要求。



它也将影响编译,就像您瞄准 .NET Core 并利用Windows特定功能或程序包一样,您将获得编译错误。



您可以通过调整 .csproj 轻松地在两者之间进行切换。



Microsoft文档


在以下情况下,应为服务器应用程序使用.NET Core:




  • 您有跨平台需求。


  • 您正在瞄准微服务。 / p>


  • 您正在使用Docker容器。


  • 您需要高性能和可扩展的系统。 / p>


  • 您需要按应用程序并排使用.NET版本。




在以下情况下,应将.NET Framework用于服务器应用程序:




  • 您的应用程序当前使用.NET Framework(建议为扩展而不是迁移)

  • 您需要使用第三方.NET库或.NET Core不可用的NuGet软件包。

  • 您需要使用无法使用的.NET技术r .NET Core。

  • 您需要使用不支持.NET Core的平台。




更新(2018/10/30)



它已经宣布具有 ASP.Net Core 3 的版本 2019年第一季度中的日期,仅支持。 NET Core .NET Framework


如本月早些时候在.NET博客上所宣布的那样,由于.NET的就地更新特性,.NET Framework将获得越来越少的.NET Core的较新平台和语言功能。框架以及限制可能会破坏现有应用程序的更改的愿望。为了确保ASP.NET Core可以充分利用向前发展的.NET Core所做的改进,ASP.NET Core仅可从3.0开始在.NET Core上运行。展望未来,您可以简单地将ASP.NET Core视为.NET Core的一部分。



如今,在.NET Framework上使用ASP.NET Core的客户可以继续做因此使用2.1 LTS版本以完全受支持的方式进行。根据.NET支持政策,对2.1的支持和服务将一直持续到至少2021年8月21日(宣布为LTS版本后的3年)。



With the release of .NET Core RC2 Microsoft made it so there are now 3 Web Application templates:

  • ASP.NET Web Application (.NET Framework) — The old
  • ASP.NET Core Web Application (.NET Framework) — the new, to be hosting on Windows only
  • ASP.NET Core Web Application (.NET Core) — Linux, OSX, Windows

I am trying to use the new Core Web Application template but without trying to target Linux, OSX, Windows so it seems like the ASP.NET Core Web Application (.NET Framework) is perfect for me. It took me a while but I learned that in order to add a class library that will work with this project type you need to add a Class Library (.NET Core) and change the frameworks section to only be net461 to match the Web Application.

"frameworks": {
    "net461": { }
}

My Question:

What is the difference between creating a ASP.NET Core Web Application (.NET Core) and in project.json making net461 the only target framework

and

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.?

解决方案

What is the difference between creating a ASP.NET Core Web Application (.NET Core) and in project.json making.NET461 the only target Framework

It's the same thing as making an ASP.NET Core Web Application (.NET Framework) project. The type of project between the two is determined by the .csproj file and you changed it in your .csproj from targeting .NET Core to targeting the .NET Framework. In previous release/beta versions of ASP.NET Core it was possible to have both Frameworks in a project.json file (which has been replaced by a simplified .csproj file in .NET Core 2.0 which more .NET developers are familiar with) but you could only publish to one.

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.

The reason for there being separate ASP.NET Core Web Application (.NET Core) and ASP.NET Core Web Application (.NET Framework) is because the latter allows you to make use of functions, packages or 3rd party libraries that are dependent on Windows and the same .NET Framework or higher will be required to be installed on the machine.

The former doesn't have the .NET Framework requirement but allows your app to be cross platform and when you publish your app it publishes all the dependent .NET Core dll files to the publish directory in that way circumventing the .NET Framework installation requirement.

It will also affect compilation as if you target .NET Core and make use of a Windows specific function or package you will get a compilation error.

You can easily switch between the two by adjusting your .csproj to target the one or the other.

Microsoft Docs

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.

Update (2018/10/30)

It has been announced that ASP.Net Core 3 which has a release date in 2019 Q1, will only support .NET Core and NOT .NET Framework

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.

这篇关于使用将net461设置为唯一框架的ASP.NET Core Web应用程序(.NET Core)与使用(.NET Framework)模板之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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