1

My unit test project has its own appsettings.json file.

In the same solution, I have an ASP.NET Core 3.1 WebAPI Project with an appsettings.json file.

I also have an ASP.NET Core 3.1 Razor project that has an appsettings.json file.

When I run my unit tests, the appsettings.json file from the WebAPI project is copied into the debug folder of my unit tests.

If I do a full rebuild, then the unit test project's appsettings.json file is copied into the debug folder. But then when I run a unit test (by pressing ctrl + R + T), the WebAPI project's appsettings.json file is again copied in.

I assumed that the appsettings.json file copied into the project's debug folder would correspond with the appsettings.json file in that project. (And it does for a full rebuild.)

How can I specify which appsettings.json file should be copied to the debug folder of a project's build?

Vaccano
  • 78,325
  • 149
  • 468
  • 850

1 Answers1

1

I am not sure what shenanigans .net core is trying to do by swapping in a different appsetting.json file, but setting my unit test project's appsettings.json file to be an embedded resource made it copy it over.

https://stackoverflow.com/a/49778593/16241

Vaccano
  • 78,325
  • 149
  • 468
  • 850