.net 核心应用程序目标 .net 框架 4.5.2 在 Linux 上

问题描述:

我想更多地了解 dot net core 支持.我的基本理解是,如果我想在 Linux 上运行一个 .net 应用程序,那么它需要构建 .net 核心和目标 netcoreapp1.0 框架来保证这一点.1)我认为上述假设是正确的?

I wanted to understand the dot net core support a bit more. My basic understanding was that if I wanted to run a .net app on Linux then it needs to be built .net core and targeted netcoreapp1.0 framework to guarantee this. 1) I assume the above assumption is correct?

2) 当我在网上阅读各种文章时,例如这篇关于在 .net 核心应用程序中引用现有 .net 框架项目的文章 (https://www.hanselman.com/blog/HowToReferenceAnExistingNETFrameworkProjectInAnASPNETCore10WebApp.aspx)如果我这样做,大概该应用程序只能在 Windows 上运行而不是在 Linux 上运行?

2) When I was reading various articles online, such as this one about referencing exiting .net framework project within a .net core application (https://www.hanselman.com/blog/HowToReferenceAnExistingNETFrameworkProjectInAnASPNETCore10WebApp.aspx) If I did this, presumably the app would only run on Windows and not Linux?

3) 在以下文章中:https://blogs.msdn.microsoft.com/cesardelatorre/2016/06/28/running-net-core-apps-on-multiple-frameworks-and-what-the-target-framework-monikers-tfms-are-about/在使用 .net run 4.5.2 选项运行的上下文中(dotnet run -f NET452),提到了:

3) In the following article: https://blogs.msdn.microsoft.com/cesardelatorre/2016/06/28/running-net-core-apps-on-multiple-frameworks-and-what-the-target-framework-monikers-tfms-are-about/ In context to running with .net run 4.5.2 option ( dotnet run -f NET452), it's mentioned:

如果此应用程序在 .NET Core 平台上运行,例如在 Linux 机器或 Mac 上,则不会执行此代码,但应用程序会仍在 Linux 或 MacOS 上运行.

运行和不执行有什么区别?如果我最初的理解是正确的,那么通过在 Linux 上使用 .net 4.5.2 选项运行,我不希望该应用程序根本无法运行.

What's the distinction between running and not executing? If my initial understanding was correct, then by running with .net 4.5.2 option on Linux I wouldn't expect the app not to run at all.

感谢那里的一些问题,但真的想更多地了解 .net core.

Appreciate a few questions there but really wanted to understand .net core a bit more.

.NET CoreASP.NET Core 有区别,你提到的文章是关于在 .NET Framework 上运行 ASP.NET Core应用程序".让我尝试使用一些声明性语句来澄清这一点:

There is a difference between .NET Core and ASP.NET Core and the articles you mentioned are about running ASP.NET Core "apps" on .NET Framework. Let my try to clarify this using a few declarative statements:

  • .NET Core 是跨平台运行时.
  • ASP.NET Core 是一组在 1.1.* 版本之前可以运行的库在 .NET Framework.NET Core 上.
  • 这意味着您可以创建一个 .NET Framework 应用程序(=> 例如net452) 并在此应用程序中使用 ASP.NET Core.
  • CLI 工具适用于面向 netcoreapp*net* - 但 net* 目前仅适用于 Windows.
  • .NET Core is the cross-platform runtime.
  • ASP.NET Core is a set of libraries that until version 1.1.* can run on both .NET Framework and .NET Core.
  • This means you can create a .NET Framework application (=> e.g. net452) and use ASP.NET Corein this application.
  • The CLI tooling works for both projects targeting netcoreapp* and net* - but net* currently only works on windows.

这意味着对于 netcoreapp1.*,您不能引用为 .NET Framework 构建的任意库.如果您将目标框架更改为 net452,则您构建的不再是 .net 核心应用程序,而是 .net 框架应用程序.

This means that for netcoreapp1.*, you cannot reference arbitrary libraries that have been built for .NET Framework. If you change the target framework to say net452, you are no longer building a .net core application, but a .net framework application.

对于 ASP.NET Core 2.0,这将会改变.再次声明:

For ASP.NET Core 2.0 this is going to change. Again a few statements:

  • ASP.NET Core 2.0 仍然是一组库,但它们只能用于 .NET Core 2.0 而不能用于 .NET Framework代码>
    • ASP.NET Core 2.0 is still a set of libraries but they can only be used on .NET Core 2.0 and not on .NET Framework
      • Do note that this is still under discussion at the time of writing: https://github.com/aspnet/Home/issues/2022
      • 但是,如果某些库尝试使用 .NET Core
      • 上不可用的 API 方法,它们可能会在运行时失败
      • However, some libraries may fail at run time if they try to use API methods that aren't available on .NET Core