I have a simple console app which needs to load its configuration from appsettings.json
. I'm publishing from VS2019 using the "Produce single file" option.
The default behaviour is for publish to place appsettings.json
inside the single file. That's no good to me because I want to be able to edit the configuration file in-place on the Linux server where it will be deployed.
It's possible to exclude appsettings.json
from the bundled file by adding an option to its entry in the project file - <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
works great and causes VS2019 to publish the appsettings.json file alongside the binary.
However...
When I run the binary (from /opt/MyApp/MyApp
), and log the location from which it's trying to load appsettings.json
, I see:
Loading settings from /var/tmp/.net/MyApp/jq1u11uk.4ap/appsettings.json
So my edited /opt/MyApp/appsettings.json
is being ignored.
Is there some intended way to keep appsettings.json
editable when using this publish option?
(This question was also asked at How to handle Appsettings for .net core 3.1 self contained single file publish, but was never answered in a way that solves being able to edit the file in-place.)