@@ -39,6 +39,9 @@ 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+ // Full path of the directory that contains the Roslyn binaries
43+ // and the hosting process has permission to access that path
44+ private const string CustomRoslynCompilerLocation = "ROSLYN_COMPILER_LOCATION" ;
4245
4346 private static ICompilerSettings _csc ;
4447 private static ICompilerSettings _vb ;
@@ -56,8 +59,17 @@ static CompilationSettingsHelper() {
5659 ttl = DefaultCompilerServerTTLInDevEnvironment ;
5760 }
5861
59- _csc = new CompilerSettings ( CompilerFullPath ( @"bin\roslyn\csc.exe" ) , ttl ) ;
60- _vb = new CompilerSettings ( CompilerFullPath ( @"bin\roslyn\vbc.exe" ) , ttl ) ;
62+ var customRoslynCompilerLocation = Environment . GetEnvironmentVariable ( CustomRoslynCompilerLocation , EnvironmentVariableTarget . Process ) ;
63+ if ( customRoslynCompilerLocation != null )
64+ {
65+ _csc = new CompilerSettings ( $ "{ customRoslynCompilerLocation } \\ csc.exe", ttl ) ;
66+ _vb = new CompilerSettings ( $ "{ customRoslynCompilerLocation } \\ vbc.exe", ttl ) ;
67+ }
68+ else
69+ {
70+ _csc = new CompilerSettings ( CompilerFullPath ( @"bin\roslyn\csc.exe" ) , ttl ) ;
71+ _vb = new CompilerSettings ( CompilerFullPath ( @"bin\roslyn\vbc.exe" ) , ttl ) ;
72+ }
6173
6274 if ( isDebuggerAttached ) {
6375 Environment . SetEnvironmentVariable ( DebuggerAttachedEnvironmentVariable , "1" , EnvironmentVariableTarget . Process ) ;
0 commit comments