Most of the coverage in @tillig's post Deep Dive into Microsoft Configuration is present in the docs. We'll improve organization and content quality on this pass. I'll react to @tillig's comment below to ensure the docs are applicable (or understood to be applicable) to any .NET Core app that wants config.
IConfiguration). However in many cases, the content might be passing mentions and not worth linking. If there are some opportunities here, then list and link out to those scenarios.IOptions<IISOptions>). Link out to the Options topic for details.IOptions used by the framework with links out to those scenarios.Advance PRs to simplify the workload for this issue:
I resolve Document overriding app settings in Azure Portal #6514 in the PR.
Syntax highlighting missing string interpolation #7207 was moved to the DocFX repo issues. It's out-of-scope for us.
Consider not focusing on _ASP.NET_ Core and ensure the docs are applicable (or understood to be applicable) to any .NET Core app that wants config. I suspect there are people who see a lot of ASP.NET references, think, "Not applicable, I'm writing for Xamarin" (or whatever), and stop reading.
Thanks for your feedback @tillig. We'll look at this subject in more detail shortly. I have a few other issues to attend first.
Great job on your post. You beat us (me) to it! We've been crazy busy. 馃弮 Our priority before reaching this issue is on-going 2.1 updates (e.g., samples). There's a light at the end of the tunnel tho. 馃殏 馃槄
That would be a great statement to say upfront.
For most of our customers using ASP.NET Core MVC and even more so, Razor Pages (RP) - there is nothing they can quickly adopt and use. Once we have something RP can easily copy and use, we can focus on the low level.
So the focus should be on RP samples.
@Rick-Anderson @scottaddie @Tratcher I've updated the OP :point_up:. This is ready for a look/discussion.
Comments? .... Concerns?
I agree that configuring a wep app is different from the Configuration APIs, but lumping them together under a Configuration topic seems like a recipe for confusion. Do we need two top level categories "Configuring Web Apps" and "Configuration APIs"? Hmm, not sure that's better...
lumping them together
I propose to do this in a section of the landing topic. I don't plan to provide details there. I'd link out and down to the specifics.
I propose to do what you said, but I recommend that we do it in a section early in the Configuration landing page. We can link out and down from there.
Today, the subject of host vs. app config is MIA early in the docs. We leave it up to the dev to piece together what's going on after they're read the "configuration" topic and the "Web Host/Generic Host" topics. A landing page that calls out the basics (and links the content) should solve this problem.
Additionally, we should consider moving the Host node earlier in the TOC. Host is an _HORRIBAD_ position imo. To me, it falls into an early app build/maintain concern. Why do we have it after ...
It seems like the config APIs warrant there own top level landing page for non-asp.net folks. Referencing that from your other landing page is fine.
[EDIT] Didn't work to have host vs app config in the Fundamentals landing page. It's buried there. I'll try including a section in the Configuration topic itself.
Sure, nothing wrong with moving Host up.
@Tratcher It appears that switch mappings are incompatible with CreateDefaultBuilder. Adding a call to AddCommandLine with a switch mappings dictionary apparently activates too late during startup.
There's no way to add a switch mapping dictionary to the AddCommandLine call inside CreateDefaultBuilder, so a mapped switch chokes immediately with dotnet run.
It seems the only way to do it is to not use CreateDefaultBuilder and do it the old fashioned way. Is that correct?
No 馃幉馃幉...
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
var switchMappings = new Dictionary<string, string>
{
{ "-CommandLineKey1", "CommandLineKey1" },
{ "-CommandLineKey2", "CommandLineKey2" }
};
var config = new ConfigurationBuilder()
.AddCommandLine(args, switchMappings)
.Build();
return WebHost.CreateDefaultBuilder(args)
.UseConfiguration(config)
.UseStartup<Startup>();
}
This works ...
public static void Main(string[] args)
{
var switchMappings = new Dictionary<string, string>
{
{ "-CommandLineKey1", "CommandLineKey1" },
{ "-CommandLineKey2", "CommandLineKey2" }
};
var config = new ConfigurationBuilder()
.AddCommandLine(args, switchMappings)
.Build();
var host = new WebHostBuilder()
.UseConfiguration(config)
.UseKestrel()
.UseStartup<Startup>()
.Start();
using (host)
{
Console.ReadLine();
}
}
That should work... Are you confusing it by passing in args twice? What if you remove args from CreateDefaultBuilder(args)?
@Tratcher The ConfigurationBinder doesn't seem to be able to bind recurring element contents (section2 > items below). It chokes saying that the items create duplicate keys in the configuration (i.e., it doesn't use the id value when creating the keys).
<top_level>
<section0>
<item0>section0-item0-value</item0>
<item1>section0-item1-value</item1>
</section0>
<section1>
<items>
<item id="item0">section1-items-item0-value</item>
<item id="item1">section1-items-item1-value</item>
<item id="item2">section1-items-item2-value</item>
</items>
</section1>
</top_level>
Is there a way, or is it just not capable of binding this scenario?
@guardrex Use name not id. name has special meaning in XML config. Example on my blog - look at the "ordinal collections" section.
Thanks @tillig!