From 5a93f68ccce94ab066341104d991d3e40dd23454 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Mon, 5 Feb 2018 14:10:32 -0800 Subject: [PATCH] Pass through DebugTool to to debug build server creation --- .../DotnetToolTask.cs | 2 +- .../ServerProtocol/ServerConnection.cs | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.AspNetCore.Razor.Tasks/DotnetToolTask.cs b/src/Microsoft.AspNetCore.Razor.Tasks/DotnetToolTask.cs index d79d6022ac..3b92bed574 100644 --- a/src/Microsoft.AspNetCore.Razor.Tasks/DotnetToolTask.cs +++ b/src/Microsoft.AspNetCore.Razor.Tasks/DotnetToolTask.cs @@ -132,7 +132,7 @@ namespace Microsoft.AspNetCore.Razor.Tasks var arguments = GetArguments(responseFileCommands); - var responseTask = ServerConnection.RunOnServer(PipeName, arguments, serverPaths, _razorServerCts.Token); + var responseTask = ServerConnection.RunOnServer(PipeName, arguments, serverPaths, _razorServerCts.Token, debug: DebugTool); responseTask.Wait(_razorServerCts.Token); var response = responseTask.Result; diff --git a/src/Microsoft.AspNetCore.Razor.Tools/ServerProtocol/ServerConnection.cs b/src/Microsoft.AspNetCore.Razor.Tools/ServerProtocol/ServerConnection.cs index 9b548e9854..2518485f6c 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/ServerProtocol/ServerConnection.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/ServerProtocol/ServerConnection.cs @@ -87,7 +87,8 @@ namespace Microsoft.AspNetCore.Razor.Tools List arguments, ServerPaths buildPaths, CancellationToken cancellationToken, - string keepAlive = null) + string keepAlive = null, + bool debug = false) { if (string.IsNullOrEmpty(pipeName)) { @@ -101,7 +102,8 @@ namespace Microsoft.AspNetCore.Razor.Tools keepAlive: keepAlive, timeoutOverride: null, tryCreateServerFunc: TryCreateServerCore, - cancellationToken: cancellationToken); + cancellationToken: cancellationToken, + debug: debug); } private static async Task RunOnServerCore( @@ -110,8 +112,9 @@ namespace Microsoft.AspNetCore.Razor.Tools string pipeName, string keepAlive, int? timeoutOverride, - Func tryCreateServerFunc, - CancellationToken cancellationToken) + Func tryCreateServerFunc, + CancellationToken cancellationToken, + bool debug) { if (pipeName == null) { @@ -154,7 +157,7 @@ namespace Microsoft.AspNetCore.Razor.Tools var wasServerRunning = WasServerMutexOpen(serverMutexName); var timeout = wasServerRunning ? timeoutExistingProcess : timeoutNewProcess; - if (wasServerRunning || tryCreateServerFunc(clientDir, pipeName)) + if (wasServerRunning || tryCreateServerFunc(clientDir, pipeName, debug)) { pipeTask = Client.ConnectAsync(pipeName, TimeSpan.FromMilliseconds(timeout), cancellationToken); } @@ -249,7 +252,7 @@ namespace Microsoft.AspNetCore.Razor.Tools } // Internal for testing. - internal static bool TryCreateServerCore(string clientDir, string pipeName) + internal static bool TryCreateServerCore(string clientDir, string pipeName, bool debug = false) { string expectedPath; string processArguments; @@ -257,7 +260,7 @@ namespace Microsoft.AspNetCore.Razor.Tools // The server should be in the same directory as the client var expectedCompilerPath = Path.Combine(clientDir, ServerName); expectedPath = Environment.GetEnvironmentVariable("DOTNET_HOST_PATH") ?? "dotnet"; - processArguments = $@"""{expectedCompilerPath}"" server -p {pipeName}"; + processArguments = $@"""{expectedCompilerPath}"" {(debug ? "--debug" : "")} server -p {pipeName}"; if (!File.Exists(expectedCompilerPath)) {