title: Accessing the IHostingEnvironment in static main of ASP.NET Core
body: <p>I'm attempting to get configuration values in my static void main of my upgraded Asp.Net Core RC2 application. In the constructor for Startup, I can get IHostingEnvironment injected in, but can't do that in a static method.
  I'm following <a href="https://github.com/aspnet/KestrelHttpServer/blob/dev/samples/SampleApp/Startup.cs" rel="nofollow">https://github.com/aspnet/KestrelHttpServer/blob/dev/samples/SampleApp/Startup.cs</a>, but want to have my pfx password in appsettings (yes, it should be in <a href="https://docs.asp.net/en/latest/security/app-secrets.html" rel="nofollow">user secrets</a> and will get there eventually).</p>
  
  <pre><code>public Startup(IHostingEnvironment env){}
  
  public static void Main(string[] args)
  {
          var builder = new ConfigurationBuilder()
              .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
              .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
              .AddJsonFile("hosting.json");
          builder.AddEnvironmentVariables();
          var configuration = builder.Build();
         ...
         var host = new WebHostBuilder()
              .UseKestrel(options =&gt;
              {
                  // options.ThreadCount = 4;
                  options.NoDelay = true;
                  options.UseHttps(testCertPath, configuration["pfxPassword"]);
                  options.UseConnectionLogging();
              })
  }
  </code></pre>