protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands) { if (ProvideCommandLineArgs) { CommandLineArgs = GetArguments(commandLineCommands, responseFileCommands) .Select(arg => new TaskItem(arg)).ToArray(); } if (SkipCompilerExecution) { return(0); } if (!UseSharedCompilation || !string.IsNullOrEmpty(ToolPath)) { return(base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands)); } using (_sharedCompileCts = new CancellationTokenSource()) { try { CompilerServerLogger.Log($"CommandLine = '{commandLineCommands}'"); CompilerServerLogger.Log($"BuildResponseFile = '{responseFileCommands}'"); var responseTask = BuildClient.TryRunServerCompilation( Language, TryGetClientDir() ?? Path.GetDirectoryName(pathToTool), CurrentDirectoryToUse(), GetArguments(commandLineCommands, responseFileCommands), _sharedCompileCts.Token, libEnvVariable: LibDirectoryToUse()); responseTask.Wait(_sharedCompileCts.Token); var response = responseTask.Result; if (response != null) { ExitCode = HandleResponse(response, pathToTool, responseFileCommands, commandLineCommands); } else { ExitCode = base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands); } } catch (OperationCanceledException) { ExitCode = 0; } catch (Exception e) { Log.LogErrorWithCodeFromResources("Compiler_UnexpectedException"); LogErrorOutput(e.ToString()); ExitCode = -1; } } return(ExitCode); }
protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands) { if (!UseSharedCompilation || this.ToolPath != null) { return(base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands)); } using (_sharedCompileCts = new CancellationTokenSource()) { try { var responseTask = BuildClient.TryRunServerCompilation( Language, TryGetClientDir() ?? Path.GetDirectoryName(pathToTool), CurrentDirectoryToUse(), GetArguments(commandLineCommands, responseFileCommands), _sharedCompileCts.Token, libEnvVariable: LibDirectoryToUse()); responseTask.Wait(_sharedCompileCts.Token); var response = responseTask.Result; if (response != null) { ExitCode = HandleResponse(response, pathToTool, responseFileCommands, commandLineCommands); } else { ExitCode = base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands); } } catch (OperationCanceledException) { ExitCode = 0; } catch (Exception e) { Log.LogErrorWithCodeFromResources("Compiler_UnexpectedException"); LogErrorOutput(e.ToString()); ExitCode = -1; } } return(ExitCode); }