msbuild的GenerateRuntimeConfigurationFiles的目的是什么? [英] What is the purpose of msbuild's GenerateRuntimeConfigurationFiles?

查看:98
本文介绍了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
  • 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 Files\dotnet\shared\Microsoft.NETCore.App\1.1.2)中寻找匹配的文件夹.这很重要,因为可以并行安装多个运行时,并且主机在运行dotnet myapp.dll时需要知道要使用哪个运行时.
  • 运行时的其他选项.最突出的可能是在桌面"和服务器"模式之间切换的垃圾收集设置.当您在csproj文件中设置<ServerGarbageCollection>true</ServerGarbageCollection>时,这将导致在runtimeconfig.json中设置一个值. (对于Web项目,此属性默认为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 Files\dotnet\shared\Microsoft.NETCore.App\1.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的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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