.NET Core 中的 *deps.json 文件 [英] The *deps.json file in .NET Core

查看:30
本文介绍了.NET Core 中的 *deps.json 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.NET Core 中 *deps.json 文件的用途是什么?将引用存储在此类文件中而不是程序集清单中(如在独立的 .NET Framework 中)的原因是什么?

What is the purpose of *deps.json file in .NET Core? What is the reason to store references in such file and not in assembly manifest(as in standalone .NET Framework)?

在 dotnet build 命令之后,我使用 Ildasm 检查程序集清单不包含这些依赖项的条目.

Using Ildasm i checked that assembly manifest doesn't contain entries for these dependecies after dotnet build command.

但它在 dotnet publish 命令之后有条目.

But it has entries after dotnet publish command.

推荐答案

.deps.json 文件包含有关由构建的程序集引用的程序集的元数据以及搜索它们的位置以及有关所用编译选项的信息.

The .deps.json file contains metadata about the assemblies referenced by the built assembly and the locations to search for them as well as information about the compilation options used.

此信息由加载和配置运行时的本机组件 (corehost) 读取.当需要加载引用的程序集时,宿主将使用此文件(以及任何runtimeconfig.json/runtimeconfig.dev.json)中的信息来定位要加载的正确程序集.

This information is read by the native component (corehost) that loads and configures the runtime. When a referenced assembly needs to be loaded, the host will use the information in this file (as well as any runtimeconfig.json/runtimeconfig.dev.json) to locate the correct assembly to load.

此信息也用于其他地方.例如 ASP.NET Core 的 Razor 视图编译也使用它来将正确的引用和配置传递给生成的代码.并且当单元测试库加载到测试主机时,单元测试主机也需要使用这个文件中的信息.Microsoft.Extensions.DependencyModel NuGet 包中提供了用于读取和写入此文件的托管 API.

This information is used in other places as well. For example ASP.NET Core's Razor view compilation also uses it to pass the correct references and configuration to the generated code. And unit test hosts also need to use the information in this file when a unit test library is loaded into the test host. The managed API to read and write this file is available in the Microsoft.Extensions.DependencyModel NuGet package.

这篇关于.NET Core 中的 *deps.json 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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