title: Use appsettings to drive environment specific settings such as UseUrls
body: <p>When I'm developing locally using VS Code, I'm going to use port 3000 because I'm a hipster. The non-hipsters want it on port 8080 on the server. That's cool, we got this. Microsoft docs give me the following example:</p>
  
  <pre><code>public static void Main(string[] args)
  {
      var config = new ConfigurationBuilder()
          .AddJsonFile("hosting.json", optional: true)
          .AddCommandLine(args)
          .Build();
  
      var host = new WebHostBuilder()
          .UseConfiguration(config)
          .UseKestrel()
          .Configure(app =&gt;
          {
              app.Run(async (context) =&gt; await context.Response.WriteAsync("Hi!"));
          })
          .Build();
  
      host.Run();
  }
  </code></pre>
  
  <p>I don't want to use <code>hosting.json</code>. Why would I want that? I have this <code>appsettings.{environment}.json</code> file for exactly this situation. Sweet, I'll just paste that bad boy in</p>
  
  <pre><code>public static void Main(string[] args)
  {
      var config = new ConfigurationBuilder()
          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
          .AddCommandLine(args)
          .Build();
  </code></pre>
  
  <p>What the compiler error? <code>env</code> does not exist in the current context. It only exists in the <code>Startup.cs</code> file--which is not called on startup, but called <em>from</em> the startup file, <code>Program.cs</code>, with sorcery.</p>
  
  <p>So, how do I solve this problem? How can I store my environment-specific hosting settings in my environment-specific <code>appsettings.json</code>, and subsequently use it in while building my environment-specific web host via the <code>WebHostBuilder</code> in <code>Program.cs</code>?</p>