< TargetFramework>有什么区别?和< RuntimeFrameworkVersion&gt ;? [英] What's the difference between <TargetFramework> and <RuntimeFrameworkVersion>?

查看:244
本文介绍了< TargetFramework>有什么区别?和< RuntimeFrameworkVersion&gt ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 csproj 文件中有以下代码:

I have the following code in a csproj file:

< TargetFramework> ; netcoreapp1.0< / TargetFramework>

在NuGet软件包管理器中,它说我有 Microsoft.NETCore.App版本1.0.5

In the NuGet package manager, it says that I have Microsoft.NETCore.App version 1.0.5

现在可以说我在同一个 csproj 文件中有以下代码:

Now lets say I have the following code in the same csproj file:

< TargetFramework> netcoreapp1.0< / TargetFramework>
< RuntimeFrameworkVersion> 1.1.4< / RuntimeFrameworkVersion>

NuGet软件包管理器现在将说我具有 Microsoft.NETCore.App版本1.1.4

The NuGet package manager will now say that I have Microsoft.NETCore.App version 1.1.4

我实际上是在尝试使用.NETCore 2.0之前的最新框架(转换时出现一些EF问题)。 1.1.4,但是 csproj 中的多个Framework属性使我不确定要使用哪个标记。我找不到任何可以清楚地区分两者之间差异的资源。

I'm essentially trying to use the latest framework before .NETCore 2.0 (having some EF issues when I converted) which would be .NETCore 1.1.4 but the multiple Framework attributes in csproj make me unsure which tag to use. I was unable to find any resources that clearly distinguishes the differences between the two.

推荐答案

TargetFramework < NuGet使用/ code>来解决依赖关系,并确定用于编译和构建应用程序的资产。 (在幕后,还有其他一些属性,例如 TargetFrameworkMoniker TargetFrameworkVersion 起作用,但SDK将其抽象为一个更简单的属性 TargetFramework 了解它的框架)。

The TargetFramework is used by NuGet to resolve dependencies and determine the assets to be used for compiling and building the application. (Behind the scenes, a few more properties like TargetFrameworkMoniker and TargetFrameworkVersion come into play but the SDK abstracts it to a simpler TargetFramework for frameworks it knows about).

RuntimeFrameworkVersion 特定于.NET Core / netcoreapp 。 SDK将为 RuntimeFrameworkVersion 设置为或使用最新版本的版本注入对 Microsoft.NETCore.App 的依赖。 .NET Core已知的版本< 2.0。然后将已解决的版本写入.NET Core主机框架解析器的 runtimeconfig.json 文件中,以解析要加载的共享框架的版本(= .NET Core 1.1 .4运行时。)

The RuntimeFrameworkVersion is specific to .NET Core / netcoreapp. The SDK will inject a dependency on Microsoft.NETCore.App for the version that RuntimeFrameworkVersion is set to or use the latest version it knows about for .NET Core < 2.0. The resolved version is then written to the runtimeconfig.json file for the .NET Core host framework resolver to resolve the version of the shared framework to load (=> .NET Core 1.1.4 runtime for example).

能够使用 1.1。* 表示<$ c $的原因c> netcoreapp1.0 是因为NuGet软件包实际上包含构建.NET Core 1.0。*应用程序所需的资产。但是该工具不知道这一点,因此您将获得一个.NET Core 1.0应用程序,但它将由1.1框架加载,因为这就是 runtimeconfig.json 文件。

The reason you are able to use 1.1.* for netcoreapp1.0 is because the NuGet package actually contains the necessary assets to build .NET Core 1.0.* applications. However the tooling doesn't know this so you'll get a .NET Core 1.0 app but it will be loaded by the 1.1 framework because that's what ends up in the runtimeconfig.json file.

重要区别是:


  • 这仅对自己重要包含的可执行文件,使用的是 Microsoft.NETCore.App 版本。


    • 在执行独立发布时(例如 dotnet publish -r win7),此软件包将提取具有所需版本的完整框架-x64

    • 运行为 1.0.3 构建的应用程序但您拥有<$安装了c $ c> 1.0.5 运行时后,将自动使用 1.0.5 运行时。

    • 如果未设置 RuntimeFrameworkVersion ,并且发布了一个新版本的SDK,它知道.NET Core的较新修补程序版本,它将自动使用最新版本。如果您显式设置版本,则不编辑项目文件就无法保持最新​​。

    • It only matters for self-contained executables which version of Microsoft.NETCore.App is used.
      • This package will pull in the complete framework with the desired version when performing a self-contained publish (e.g. dotnet publish -r win7-x64)
      • When you run an application built for 1.0.3 but you have the 1.0.5 runtime installed, the 1.0.5 runtime will be used automatically.
      • If you don't set RuntimeFrameworkVersion and a new version of the SDK is released that knows about newer patch versions of .NET Core, it will use the newest version automatically. If you set the version explicitly, you may not be up-to-date without editing the project file.

      除了这些,只有少数几个理由使用 Microsoft.NETCore.App的更高版本进行构建,就像 DiaSymReader 组件的构建错误修正。

      Apart from these, there are only a few reasons to build using a higher version of Microsoft.NETCore.App, like a build bugfix for the DiaSymReader component.

      在.NET Core 2.0中,对于便携式应用程序(非自包含), RuntimeFrameworkVersion 的版本始终为 2.0.0 Microsoft.NETCore.App 的依赖项不再提供该框架,并且此NuGet包仅用于提供用于编译的参考程序集。

      In .NET Core 2.0, the version of RuntimeFrameworkVersion will always be 2.0.0 for "portable applications" (non-self contained) because the implementation of the framework is no longer provided by the dependencies of Microsoft.NETCore.App and this NuGet package is only used to provide reference assemblies for compilation.

      这篇关于&lt; TargetFramework&gt;有什么区别?和&lt; RuntimeFrameworkVersion&gt ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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