@@ -85,7 +85,11 @@ public static async Task Main(string[] args)
8585 } ;
8686
8787 bool inVScode = ( Environment . GetEnvironmentVariable ( "RUNNING_IN_VSCODE" ) ?? "" ) == "true" ;
88+ bool reloadConfigOnChange = ! inDocker ;
8889
90+ // TODO: 1. Reorder the config loading so that command line is last
91+ // 2. Stop appsettings being reloaded on change when in docker for the default
92+ // appsettings.json files
8993 IHost ? host = CreateHostBuilder ( args )
9094 . ConfigureAppConfiguration ( ( hostingContext , config ) =>
9195 {
@@ -95,36 +99,36 @@ public static async Task Main(string[] args)
9599 if ( inVScode && platform != "windows" )
96100 {
97101 config . AddJsonFile ( Path . Combine ( baseDir , "appsettings.json" ) ,
98- optional : false , reloadOnChange : true ) ;
102+ optional : false , reloadOnChange : reloadConfigOnChange ) ;
99103
100104 if ( ! string . IsNullOrWhiteSpace ( aspNetEnv ) )
101105 {
102106 config . AddJsonFile ( Path . Combine ( baseDir , $ "appsettings.{ aspNetEnv } .json") ,
103- optional : true , reloadOnChange : true ) ;
107+ optional : true , reloadOnChange : reloadConfigOnChange ) ;
104108 }
105109 }
106110
107111 config . AddJsonFile ( Path . Combine ( baseDir , $ "appsettings.{ platform } .json") ,
108- optional : true , reloadOnChange : true ) ;
112+ optional : true , reloadOnChange : reloadConfigOnChange ) ;
109113
110114 // Load appsettings.platform.env.json files to allow slightly more
111115 // convenience for settings on other platforms
112116 if ( ! string . IsNullOrWhiteSpace ( aspNetEnv ) )
113117 {
114118 config . AddJsonFile ( Path . Combine ( baseDir , $ "appsettings.{ platform } .{ aspNetEnv } .json") ,
115- optional : true , reloadOnChange : true ) ;
119+ optional : true , reloadOnChange : reloadConfigOnChange ) ;
116120 }
117121
118122 // This allows us to add ad-hoc settings such as ApplicationDataDir
119123 config . AddInMemoryCollection ( inMemoryConfigData ) ;
120124
121125 // Load the installconfig.json file so we have access to the install ID
122126 config . AddJsonFile ( Path . Combine ( applicationDataDir , InstallConfig . InstallCfgFilename ) ,
123- reloadOnChange : true , optional : true ) ;
127+ reloadOnChange : reloadConfigOnChange , optional : true ) ;
124128
125129 // Load the version.json file so we have access to the Version info
126130 config . AddJsonFile ( Path . Combine ( baseDir , VersionConfig . VersionCfgFilename ) ,
127- reloadOnChange : true , optional : true ) ;
131+ reloadOnChange : reloadConfigOnChange , optional : true ) ;
128132
129133 // Load the modulesettings.json files to get analysis module settings
130134 LoadModulesConfiguration ( config , aspNetEnv ) ;
@@ -198,6 +202,8 @@ public static async Task Main(string[] args)
198202 // things. To be done at a later date.
199203 private static void LoadModulesConfiguration ( IConfigurationBuilder config , string ? aspNetEnv )
200204 {
205+ bool reloadOnChange = ( Environment . GetEnvironmentVariable ( "DOTNET_RUNNING_IN_CONTAINER" ) ?? "" ) != "true" ;
206+
201207 IConfiguration configuration = config . Build ( ) ;
202208 var options = configuration . GetSection ( "FrontEndOptions" ) ;
203209 string ? rootPath = options [ "ROOT_PATH" ] ;
@@ -243,21 +249,21 @@ private static void LoadModulesConfiguration(IConfigurationBuilder config, strin
243249 foreach ( string ? directory in directories )
244250 {
245251 config . AddJsonFile ( Path . Combine ( directory , "modulesettings.json" ) ,
246- optional : true , reloadOnChange : true ) ;
252+ optional : true , reloadOnChange : reloadOnChange ) ;
247253
248254 if ( ! string . IsNullOrEmpty ( aspNetEnv ) )
249255 {
250256 config . AddJsonFile ( Path . Combine ( directory , $ "modulesettings.{ aspNetEnv } .json") ,
251- optional : true , reloadOnChange : true ) ;
257+ optional : true , reloadOnChange : reloadOnChange ) ;
252258 }
253259
254260 config . AddJsonFile ( Path . Combine ( directory , $ "modulesettings.{ platform } .json") ,
255- optional : true , reloadOnChange : true ) ;
261+ optional : true , reloadOnChange : reloadOnChange ) ;
256262
257263 if ( ! string . IsNullOrEmpty ( aspNetEnv ) )
258264 {
259265 config . AddJsonFile ( Path . Combine ( directory , $ "modulesettings.{ platform } .{ aspNetEnv } .json") ,
260- optional : true , reloadOnChange : true ) ;
266+ optional : true , reloadOnChange : reloadOnChange ) ;
261267 }
262268 }
263269 }
0 commit comments