How is content root path handled when clearing configuration sources? #109671
Unanswered
AnthonyMastrean
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My team produces Windows services and depends on this content root path behavior that changed in .NET 7.
https://learn.microsoft.com/en-us/dotnet/core/compatibility/extensions/7.0/contentrootpath-hosted-app
However, due to security configurations, our customers expect any configuration files in the content root path to be read-only. We must provide writable configuration files in an application-specific subfolder of
Environment.SpecialFolder.CommonApplicationData
(AKAC:\ProgramData
).The recommendation for adding a JSON configuration source before the appsettings files has been to "clear sources" or to start with an empty host builder and build up sources from scratch.
I don't know about you, but I'm uncomfortable with these recommendations when I can't reproduce the same default configuration sources in the same order. From what I can tell, the following configuration sources are applied:
https://source.dot.net/#Microsoft.Extensions.Hosting/HostApplicationBuilder.cs,84
Here are the options I'm testing:
ContentRootPath
may already be applied thanks to the private/internal apply defaults and initialize calls... trust that you don't have to readd those other sources that you don't have access to (SetDefaultContentRoot
)?Should we just clear sources and move on? Are those earlier sources that I can't recreate just sorted out somehow (closed over by IHostEnvironment and service registration)?
What am I missing?
Beta Was this translation helpful? Give feedback.
All reactions