@@ -39,6 +39,7 @@ internal static class CompilationSettingsHelper {
39
39
private const int DefaultCompilerServerTTLInDevEnvironment = 60 * 15 ;
40
40
private const string DevEnvironmentVariableName = "DEV_ENVIRONMENT" ;
41
41
private const string DebuggerAttachedEnvironmentVariable = "IN_DEBUG_MODE" ;
42
+ private const string CustomTTLEnvironmentVariableName = "VBCSCOMPILER_TTL" ; // the setting value is in seconds
42
43
// Full path of the directory that contains the Roslyn binaries
43
44
// and the hosting process has permission to access that path
44
45
private const string CustomRoslynCompilerLocation = "ROSLYN_COMPILER_LOCATION" ;
@@ -51,12 +52,23 @@ static CompilationSettingsHelper() {
51
52
var devEnvironmentSetting = Environment . GetEnvironmentVariable ( DevEnvironmentVariableName , EnvironmentVariableTarget . Process ) ;
52
53
var debuggerAttachedEnvironmentSetting = Environment . GetEnvironmentVariable ( DebuggerAttachedEnvironmentVariable ,
53
54
EnvironmentVariableTarget . Process ) ;
55
+ var customTtlSetting = Environment . GetEnvironmentVariable ( CustomTTLEnvironmentVariableName , EnvironmentVariableTarget . Process ) ;
54
56
var isDebuggerAttached = IsDebuggerAttached ;
57
+ int customTtl ;
55
58
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
+ }
60
72
}
61
73
62
74
var customRoslynCompilerLocation = Environment . GetEnvironmentVariable ( CustomRoslynCompilerLocation , EnvironmentVariableTarget . Process ) ;
0 commit comments