NET5 + F# - How to build several console applications into one folder

Viewed 98

Let's say that I have two F# projects targeting NET5 and producing console applications. Let's call them MyService and MyAdminConsole. When I build the solution, then the folders, e.g. ...\MyService\bin\x64\Debug\net5.0 and ...\MyAdminConsole\bin\x64\Debug\net5.0 will contain:

...
appsettings.json
...
MyService.exe
MyService.dll
MyService.deps.json 
MyService.runtimeconfig.json
MyService.runtimeconfig.dev.json
...

and

...
MyAdminConsole.exe
MyAdminConsole.dll
MyAdminConsole.deps.json 
MyAdminConsole.runtimeconfig.json
MyAdminConsole.runtimeconfig.dev.json
...

where appsettings.json, obviously, exists only in MyService because it is the service, which needs the settings.

Now, I want to build both the service and the admin console into the same folder so that admin console could have access to the same appsettings.json and I stress the same appsettings.json, not a copy of it.

This seems straightforward, right? Just add a reference to MyAdminConsole into MyService project. However, when I rebuild the solution, then MyAdminConsole.exe and MyAdminConsole.dll are copied into ...\MyService\bin\x64\Debug\net5.0 but MyAdminConsole.*.json are not. Subsequently, MyAdminConsole won't work from that folder.

Sure, I can add post build steps and actually copy these json files where needed. However, that seems ugly and just plain wrong.

I wonder what is a proper solution? Thanks.

PS This is probably applicable to C# solutions as well but I have not checked that yet.

1 Answers
Related