ServerGarbageCollection

ServerGarbageCollection

本文介绍了msbuild 的 GenerateRuntimeConfigurationFiles 的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将一个 netcore1.1 项目升级到新的 VS2017/csproj.

I upgraded a netcore1.1 project to the new VS2017/csproj.

仅在我的测试项目中,它添加了:

In my test projects only, it added:

<PropertyGroup>
  <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>

我做了一些挖掘发现它在bin目录下生成了这些文件:

I did some digging to discover that it generates these files in the bin directory:

  • ProjectName.Tests.runtimeconfig.json
  • ProjectName.Tests.runtimeconfig.dev.json

这个设置和这些文件是什么,我为什么需要它们?

What is this setting and these files, and why do I need them?

为什么它们只为我的测试项目生成?

Why were they only generated for my test projects?

推荐答案

这些特定于 .NET Core 项目并指定

These are specific to .NET Core projects and specify

  • 要使用的运行时和版本.通常Microsoft.NETCore.App.主机框架解析器"在 shared 文件夹(例如 C:Program FilesdotnetsharedMicrosoft.NETCore.App1.1.2)中查找匹配的文件夹).这很重要,因为可以并行安装多个运行时,并且当您运行 dotnet myapp.dll 时,主机需要知道要使用哪个运行时.
  • 运行时的其他选项.最突出的可能是在桌面"和服务器"模式之间切换的垃圾收集设置.当您在 csproj 文件中设置 <ServerGarbageCollection>true</ServerGarbageCollection> 时,这将导致在 runtimeconfig.json 中设置一个值.(对于网络项目,此属性默认为 true)
  • 主机的其他选项.例如,additionalProbingPath 设置为包含已恢复包的本地 NuGet 缓存.您可能已经注意到,引用 NuGet 包不会导致其 dll 文件被复制到输出目录(默认情况下).主机使用额外的探测路径来查找在这个位置引用的包/dll(实际上它是一个两步查找:deps.json 告诉主机要使用哪些包,这个属性告诉主机在哪里寻找这个包).由于这仅用于开发而不应出现在已发布的输出中(因为这意味着依赖目标上的 NuGet 缓存),因此将此设置放入 runtimeconfig.dev.json.
  • Which runtime and version to use. Typically Microsoft.NETCore.App. The "host framework resolver" looks for a matching folder inside the shared folder (e.g. C:Program FilesdotnetsharedMicrosoft.NETCore.App1.1.2). This is important since multiple runtimes can be installed side-by-side and the host needs to know which one to use when you run dotnet myapp.dll.
  • Additional options for the runtime. The most prominent is probably the garbage collection setting that switches between "desktop" and "server" mode. When you set <ServerGarbageCollection>true</ServerGarbageCollection> int he csproj file, this will cause a value in the runtimeconfig.json to be set. (This property is defaulted to true for web projects)
  • Additional options for the host. additionalProbingPath for example is set to your local NuGet cache which contains the restored packages. You may have noticed that referencing a NuGet package does not cause its dll files to be copied to the output directory (by default). The host uses the additional probing path to look for packages / dlls referenced to in this location (actually it is a two-step lookup: deps.json tells the host which packages to use and this property tells where to look for this package). Since this is only used for development and shouldn't end up in the published output (since this would mean relying on a NuGet cache on the target), this settings is put into a runtimeconfig.dev.json.

经典".NET Framework 项目还有一个让应用程序设置一些运行时设置的概念.这是通过使用 .exe.config 文件(如果存在的话,可以从项目中的 App.config 文件构建)来实现的.您可以将 runtimeconfig.json 视为新的 .exe.config",但只有一些重叠的问题.

"Classic" .NET Framework projects also had a concept of letting the application set some runtime settings. This was accomplished by having an .exe.config file (which would be built from an App.config file in a project if present). You can think of runtimeconfig.json as "the new .exe.config" but the only have a few overlapping concerns.

这篇关于msbuild 的 GenerateRuntimeConfigurationFiles 的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 02:23