6

In my ASP.NET Core project the .json settings files are group under the main one. But if I use .yml instead, it won't do that.
In the old csproj there was a lot of XML for these kinds of things. But can't find any references to the settings files in it now.

VS

What kind of magic does this to the .json files?

VMAtm
  • 27,943
  • 17
  • 79
  • 125
Allrameest
  • 4,364
  • 2
  • 34
  • 50

2 Answers2

12

As this answer suggest, use XML similar to:

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

enter image description here

Note that you need the Update, not Include attribute

Allrameest
  • 4,364
  • 2
  • 34
  • 50
VMAtm
  • 27,943
  • 17
  • 79
  • 125
  • I guess this works, but would be nice to not have to do this with yml when I don't have to do it with json... – Allrameest Nov 09 '17 at 22:18
  • 5
    Well, I guess, this is a pre-defined behavior for `appsettings.json`. I don't think that this will be the same for any other json (not tested) – VMAtm Nov 09 '17 at 23:31
2

Have a look at the File Nesting extension provided by Mads Kristensen, if you haven't already. According to the description, this allows you to both manually nest files and set up your own rules for automatic nesting.

You can just search for this under the Visual Studio Extensions and Updates component.

EDIT: According to the known issues, this is not supported in all project types:

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

Community
  • 1
  • 1
Kirk Larkin
  • 84,915
  • 16
  • 214
  • 203