title: How to switch configuration while debugging .Net core 2.x app?
body: <p>Have been looking for the right way to add configurations to my dot net core 2.0 web API.</p>
  
  <p>Until now what I have done is:</p>
  
  <ol>
  <li><p>Added appsetteings.Development.json, appsetteings.Production.json</p></li>
  <li><p>In program.cs:</p>
  
  <pre><code>public static IWebHost BuildWebHost(string[] args)
  {
      return WebHost.CreateDefaultBuilder(args)
          .UseStartup&lt;Startup&gt;()
          .ConfigureAppConfiguration((hostContext, config) =&gt;
          {
              var env = hostContext.HostingEnvironment;
              config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                  .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
          })
          .Build();
  }
  </code></pre></li>
  <li><p>In startup.cs</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      services.AddMvc();
      services.Configure&lt;dynamic&gt;(Configuration);
  }
  </code></pre></li>
  </ol>
  
  <p>The issue is whenever I debug my code it always takes settings from <code>appsettings.Development.json</code>.</p>
  
  <p>I also found that the <code>hostContext.HostingEnvironment.EnvironmentName</code> always comes as development regardless of which environment I pick to debug in.</p>