使用 .NET Core 项目在 Visual Studio 中的其他文件下方显示文件

Showing file beneath other in Visual Studio with .NET Core project

在我的 ASP.NET 核心项目中,.json 设置文件分组在主要文件下。但是,如果我改用 .yml,它就不会那样做。
在旧的 csproj 中,有很多 XML 用于此类事情。但是现在在其中找不到任何对设置文件的引用。

这对 .json 文件有什么魔力?

按照的建议,使用XML类似于:

<None Update="appsettings.*.yml">
  <DependentUpon>appsettings.yml</DependentUpon>
</None>

请注意,您需要 Update,而不是 Include 属性

看看 Mads Kristensen 提供的 File Nesting 扩展,如果您还没有的话。根据描述,这允许您既可以手动嵌套文件,也可以设置自己的自动嵌套规则。

您可以在 Visual Studio 扩展和更新组件下搜索它。

编辑:根据已知问题,并非所有项目类型都支持此功能:

Due to missing or limited support for file nesting in certain project types, this extension will have no effect or be disabled. The project types are:

Node.js projects (NTVS)
ASP.NET Core (has built in rules for nesting)
Apache Cordova
Shared projects