0

I have multiple project under the same solution. My concern is the following:

Is there any way to aggregate all appsettings.json from different projects into one file in the same solution ?

1 Answer 1

1

If you are using Visual Studio, use may use "Add as Link" feature (for other code editors, change .csproj manually as described after image):

  • put your 'appsettings.json' into solution folder (one level higher from project folder) for example;
  • for each project in solution:
    1. right-click project name in Solution Explorer
    2. in context menu: Add -> Existing item (Shift + Alt + A)
    3. navigate to appsettings.json file
    4. use drop-down of "Add" button and click "Add as link" (see screenshot below)
    5. you will see "appsettings.json" added to your project with small arrow on icon
    6. right-click that file, click Properties, and set "Copy to output directory" to "Copy always" or "Copy if newer".

Image of "Add as Link" button option

After you save you project, you will see this new lines in .csproj file (add them manually if you use code editor other than VS, without "Add as link" option):

<ItemGroup>
  <Content Include="..\appsettings.json" Link="appsettings.json">
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  </Content>
</ItemGroup>

After that, building that project (from VS or with 'dotnet build') puts "appsettings.json" into your output build folder.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.