title: appSetting.Development.json not injected during Debug on ASP.Net Core App
body: <p>I have the following in my <code>appSetting.json</code>;</p>
  
  <pre><code>{
    "Logging": {
      "LogLevel": {
        "Default": "Warning"
      }
    },
    "AllowedHosts": "*",
    "MailServiceSettings": {
      "SmtpServer": "&lt;server&gt;",
      "ToAddresses": [
        "email@domain.com",
        "email2@domain.com"
      ],
      "UserName": "username",
      "Password": "password"
    }
  }
  </code></pre>
  
  <p>and in <code>appSettings.Development.json</code> i have a subtle change;</p>
  
  <pre><code>{
    "Logging": {
      "LogLevel": {
        "Default": "Warning"
      }
    },
    "AllowedHosts": "*",
    "MailServiceSettings": {
      "SmtpServer": "&lt;server&gt;",
      "ToAddresses": [
        "development@domain.com"
      ],
      "UserName": "username",
      "Password": "password"
    }
  }
  </code></pre>
  
  <p>This is so I can text the mail sender settings in my localhost without bombarding the live mailbox. </p>
  
  <p>However, when I run in debug the settings from <code>appSettings.json</code> are being injected insted of the <code>appSettings.Development.json</code>.</p>
  
  <p>My <code>Program.cs</code> is using the default <code>WebHostBuilder</code>;</p>
  
  <pre><code>public class Program
  {
      public static void Main(string[] args)
      {
          CreateWebHostBuilder(args)
              .Build().Run();
      }
  
      public static IWebHostBuilder CreateWebHostBuilder(string[] args) =&gt;
          WebHost.CreateDefaultBuilder(args)
  }
  </code></pre>
  
  <p>and setup the DI as following in my <code>StartUp.cs</code>;</p>
  
  <pre><code>    public void ConfigureServices(IServiceCollection services)
      {
          services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
          services.Configure&lt;MailServiceSettings&gt;(Configuration.GetSection("MailServiceSettings"));
  
          // In production, the Angular files will be served from this directory
          services.AddSpaStaticFiles(configuration =&gt;
          {
              configuration.RootPath = "ClientApp/dist";
          });
      }
  </code></pre>
  
  <p>Then when I debug and break on the configuration I can see that the <code>appSettings.Development.json</code> have been read (as I can drill down into the <code>Configuration</code> sections when debugging I can see they are added as an additional entry, and I believe <code>WebHost.CreateDefaultbuilder</code> adds the <code>env.EnvironmentName</code> files by default).</p>
  
  <p>However, when I then instantiate an controller method;</p>
  
  <pre><code>public ContactController(IOptions&lt;MailServiceSettings&gt; mailSettings, IHostingEnvironment hostingEnvironment)
  {
      _mailSettings = mailSettings;
      _hostingEnvironment = hostingEnvironment;
  }
  </code></pre>
  
  <p>I am finding that the 2x email address from the <code>appSettings.json</code> are injected instead of the <code>appSettings.Development.json</code></p>
  
  <p>I have also checked <code>env.IsDevelopment()</code> at runtime and this is returning <code>true</code>.</p>
  
  <p>Can anyone tell me what I am doing wrong here?</p>