@@ -39,6 +39,7 @@ internal static class CompilationSettingsHelper {
3939 private const int DefaultCompilerServerTTLInDevEnvironment = 60 * 15 ;
4040 private const string DevEnvironmentVariableName = "DEV_ENVIRONMENT" ;
4141 private const string DebuggerAttachedEnvironmentVariable = "IN_DEBUG_MODE" ;
42+ private const string CustomTTLEnvironmentVariableName = "VBCSCOMPILER_TTL" ; // the setting value is in seconds
4243 // Full path of the directory that contains the Roslyn binaries
4344 // and the hosting process has permission to access that path
4445 private const string CustomRoslynCompilerLocation = "ROSLYN_COMPILER_LOCATION" ;
@@ -51,12 +52,23 @@ static CompilationSettingsHelper() {
5152 var devEnvironmentSetting = Environment . GetEnvironmentVariable ( DevEnvironmentVariableName , EnvironmentVariableTarget . Process ) ;
5253 var debuggerAttachedEnvironmentSetting = Environment . GetEnvironmentVariable ( DebuggerAttachedEnvironmentVariable ,
5354 EnvironmentVariableTarget . Process ) ;
55+ var customTtlSetting = Environment . GetEnvironmentVariable ( CustomTTLEnvironmentVariableName , EnvironmentVariableTarget . Process ) ;
5456 var isDebuggerAttached = IsDebuggerAttached ;
57+ int customTtl ;
5558
56- if ( ! string . IsNullOrEmpty ( devEnvironmentSetting ) ||
57- ! string . IsNullOrEmpty ( debuggerAttachedEnvironmentSetting ) ||
58- isDebuggerAttached ) {
59- ttl = DefaultCompilerServerTTLInDevEnvironment ;
59+ // custom TTL setting always win
60+ if ( int . TryParse ( customTtlSetting , out customTtl ) )
61+ {
62+ ttl = customTtl ;
63+ }
64+ else
65+ {
66+ if ( ! string . IsNullOrEmpty ( devEnvironmentSetting ) ||
67+ ! string . IsNullOrEmpty ( debuggerAttachedEnvironmentSetting ) ||
68+ isDebuggerAttached )
69+ {
70+ ttl = DefaultCompilerServerTTLInDevEnvironment ;
71+ }
6072 }
6173
6274 var customRoslynCompilerLocation = Environment . GetEnvironmentVariable ( CustomRoslynCompilerLocation , EnvironmentVariableTarget . Process ) ;
0 commit comments