File tree Expand file tree Collapse file tree
ProjectTemplates/ReferenceProject Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55using Microsoft . Extensions . Configuration ;
66using Serilog ;
77using Microsoft . Extensions . Hosting ;
8+ using System . IO ;
89
910namespace ReferenceProject
1011{
@@ -18,6 +19,14 @@ public static void Main(string[] args)
1819 public static IHostBuilder CreateHostBuilder ( string [ ] args ) =>
1920 Host . CreateDefaultBuilder ( args )
2021 . UseServiceProviderFactory ( new AutofacServiceProviderFactory ( ) )
22+ . ConfigureAppConfiguration ( ( hostingContext , config ) =>
23+ {
24+ // https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#using-environment-variables-in-configuration-options
25+ var envPath = Path . Combine ( hostingContext . HostingEnvironment . ContentRootPath , ".env" ) ;
26+ DotNetEnv . Env . Load ( envPath ) ;
27+
28+ config . AddEnvironmentVariables ( ) ;
29+ } )
2130 . ConfigureLogging ( ( context , logging ) =>
2231 {
2332 logging . ClearProviders ( ) ;
@@ -34,10 +43,6 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
3443 . ReadFrom . Configuration ( context . Configuration )
3544 . CreateLogger ( ) ) ;
3645 } )
37- . ConfigureAppConfiguration ( x =>
38- {
39- x . AddEnvironmentVariables ( ) ;
40- } )
4146 . ConfigureWebHostDefaults ( webBuilder =>
4247 {
4348 webBuilder . UseStartup < Startup > ( ) ;
Original file line number Diff line number Diff line change @@ -37,10 +37,6 @@ public Startup(IConfiguration configuration, IHostEnvironment env)
3737 {
3838 Startup . Configuration = configuration ;
3939
40- // https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#using-environment-variables-in-configuration-options
41- var envPath = Path . Combine ( env . ContentRootPath , ".env" ) ;
42- DotNetEnv . Env . Load ( envPath ) ;
43-
4440 // See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#content-formatting
4541 JsonConvert . DefaultSettings = ( ) =>
4642 {
You can’t perform that action at this time.
0 commit comments