visual-studio-2022.net-8.0appsettings

In VS (2022) how do I get appsetting.{environment}.json under appsetting.json when "envionment" has a dot in it


If I add an appsetting.{environment}.json to the project, normal it will automatically show up under the appsetting.json.
For example I added one for environment "Test".
enter image description here

But if I add one for environment "New.New" it does not show up under appsetting.json.
enter image description here

Is there any way to get appsettings.New.New.json showing under appsetting.json


Solution

  • You can adjust the file nesting rules; see the documentation.

    Because of this double additional .New.New extension in the middle, I only get success by setting up a custom FileToFile rule, which requires the entire file name .

    Create a .filenesting.json file in your project folder or in the solution folder and add below rule that defines that appsettings.New.New.json should be nested under appsettings.json.

    {
      "help": "https://go.microsoft.com/fwlink/?linkid=866610",
      "root": false,
      "dependentFileProviders": {
        "add": {
          "fileToFile": {
            "add": {
              "appsettings.New.New.json": [
                "appsettings.json"
              ]
            }
          }
        }
      }
    }
    

    Visual Studio will show the expected nesting.

    enter image description here