diff --git a/src/Microsoft.AspNetCore.Razor.Tools/ShutdownCommand.cs b/src/Microsoft.AspNetCore.Razor.Tools/ShutdownCommand.cs index f77b30f5b2..3e0907774b 100644 --- a/src/Microsoft.AspNetCore.Razor.Tools/ShutdownCommand.cs +++ b/src/Microsoft.AspNetCore.Razor.Tools/ShutdownCommand.cs @@ -57,19 +57,21 @@ namespace Microsoft.AspNetCore.Razor.Tools var process = Process.GetProcessById(response.ServerProcessId); process.WaitForExit(); } - catch (Exception) + catch (Exception ex) { // There is an inherent race here with the server process. If it has already shutdown - // by the time we try to access it then the operation has succeed. + // by the time we try to access it then the operation has succeeded. + Error.Write(ex); } Out.Write("Server pid:{0} shut down", response.ServerProcessId); } } } - catch (Exception) when (IsServerRunning()) + catch (Exception ex) when (IsServerRunning()) { // Ignore an exception that occurred while the server was shutting down. + Error.Write(ex); } return 0; diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs index a628f5224a..7f3933c0da 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildServerTestFixture.cs @@ -31,16 +31,23 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests // Shutdown the build server. using (var cts = new CancellationTokenSource(_defaultShutdownTimeout)) { + var writer = new StringWriter(); + cts.Token.Register(() => { - throw new TimeoutException($"Shutting down the build server at pipe {PipeName} took longer than expected."); + var output = writer.ToString(); + throw new TimeoutException($"Shutting down the build server at pipe {PipeName} took longer than expected.{Environment.NewLine}Output: {output}."); }); - var application = new Application(cts.Token, Mock.Of(), Mock.Of(), (path, properties) => Mock.Of()); + var application = new Application(cts.Token, Mock.Of(), Mock.Of(), (path, properties) => Mock.Of()) + { + Out = writer, + Error = writer, + }; var exitCode = application.Execute("shutdown", "-w", "-p", PipeName); if (exitCode != 0) { - var output = application.Error.ToString(); + var output = writer.ToString(); throw new InvalidOperationException( $"Build server at pipe {PipeName} failed to shutdown with exit code {exitCode}. Output: {output}"); } diff --git a/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs b/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs index 9f8f059b87..b99de60bd2 100644 --- a/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Tools.Test/ServerLifecycleTest.cs @@ -203,7 +203,8 @@ namespace Microsoft.AspNetCore.Razor.Tools } } - [Fact] + [ConditionalFact(Skip = "https://github.com/aspnet/Razor/issues/1991")] + [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] public async Task ServerRunning_CancelCompilation_CancelsSuccessfully() { // Arrange