/// <summary> /// Run a compilation through the compiler server and print the output /// to the console. If the compiler server fails, run the fallback /// compiler. /// </summary> internal RunCompilationResult RunCompilation(IEnumerable <string> originalArguments, BuildPathsAlt buildPaths, TextWriter textWriter = null) { textWriter = textWriter ?? Console.Out; var args = originalArguments.Select(arg => arg.Trim()).ToArray(); bool hasShared; string keepAlive; string errorMessage; string sessionKey; List <string> parsedArgs; if (!ReflCommandLineParser.TryParseClientArgs( args, out parsedArgs, out hasShared, out keepAlive, out sessionKey, out errorMessage)) { Console.Out.WriteLine(errorMessage); return(RunCompilationResult.Failed); } // It's okay, and expected, for the server compilation to fail. In that case just fall // back to normal compilation. var exitCode = RunLocalCompilation(parsedArgs.ToArray(), buildPaths, textWriter); return(new RunCompilationResult(exitCode)); }
public CommonCompiler(CommandLineParser parser, string responseFile, string[] args, string clientDirectory, string baseDirectory, string sdkDirectoryOpt, string additionalReferenceDirectories, IAnalyzerAssemblyLoader analyzerLoader) { IEnumerable <string> allArgs = args; _clientDirectory = clientDirectory; Debug.Assert(null == responseFile || ReflPathUtilities.IsAbsolute(responseFile)); if (!SuppressDefaultResponseFile(args) && File.Exists(responseFile)) { allArgs = new[] { "@" + responseFile }.Concat(allArgs); } this.Arguments = parser.Parse(allArgs, baseDirectory, sdkDirectoryOpt, additionalReferenceDirectories); this.MessageProvider = ReflCommandLineParser.get_MessageProvider(parser); this.AnalyzerLoader = analyzerLoader; if (Arguments.ParseOptions.Features.ContainsKey("debug-determinism")) { EmitDeterminismKey(Arguments, args, baseDirectory, parser); } }