title: How to properly set up configuration in a .NET 5 console app?
body: <p>I've got a .NET Framework console app I'm trying to update to .NET 5, but it's failing on certain points that require data from <code>app.config</code>.</p>
  <p>The <a href="https://docs.microsoft.com/en-us/dotnet/core/extensions/configuration" rel="noreferrer">relevant</a> <a href="https://docs.microsoft.com/en-us/dotnet/core/extensions/configuration-providers" rel="noreferrer">documentation</a> on how config works now quite helpfully has all of its examples as console apps... right up until you actually look at the examples, which are completely <em>unhelpful.</em> They're all based around a <code>Main</code> block that looks like this:</p>
  <pre><code>        static async Task Main(string[] args)
          {
              using IHost host = CreateHostBuilder(args).Build();
  
              // Application code should start here.
  
              await host.RunAsync();
          }
  </code></pre>
  <p>A console app isn't a WinForms app.  The application code doesn't &quot;start&quot; in Main; <code>Main</code> is the main body of your program, which means that putting the line that makes configuration actually work <em>at the end of the method</em> means it will never be hit until the program is ready to terminate!</p>
  <p>What am I missing?  These documentation examples appear entirely pointless.  I'm not trying to host any services; I just want my existing <code>app.config</code> to be read at startup and made available to the config system, exactly the way it used to work in .NET Framework.  What's the proper way to get the old behavior back?</p>