From f3a4cf0ea7500a4ab84840a2aecdfe2d2a338c93 Mon Sep 17 00:00:00 2001 From: Praburaj Date: Mon, 20 Apr 2015 16:00:47 -0700 Subject: [PATCH] Fixing the CreateNoWindow=false issue on selfhost When CreateNoWindow is set to false, I see the selfhost process exiting immediately after start due to https://github.com/aspnet/Hosting/issues/140. To fix this I'm manually redirecting the stderror and stdoutput streams so test runs will have necessary logs. --- .../Deployers/SelfHostDeployer.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.Server.Testing/Deployers/SelfHostDeployer.cs b/src/Microsoft.AspNet.Server.Testing/Deployers/SelfHostDeployer.cs index 5e971664f0..fe27167442 100644 --- a/src/Microsoft.AspNet.Server.Testing/Deployers/SelfHostDeployer.cs +++ b/src/Microsoft.AspNet.Server.Testing/Deployers/SelfHostDeployer.cs @@ -58,12 +58,19 @@ namespace Microsoft.AspNet.Server.Testing FileName = dnxPath, Arguments = string.Format("\"{0}\" {1} --server.urls {2}", DeploymentParameters.ApplicationPath, commandName, DeploymentParameters.ApplicationBaseUriHint), UseShellExecute = false, - CreateNoWindow = false + // https://github.com/aspnet/Hosting/issues/140 causing host process to exit when this is made false. + CreateNoWindow = true, + RedirectStandardError = true, + RedirectStandardOutput = true }; AddEnvironmentVariablesToProcess(startInfo); _hostProcess = Process.Start(startInfo); + _hostProcess.BeginErrorReadLine(); + _hostProcess.BeginOutputReadLine(); + _hostProcess.ErrorDataReceived += (sender, dataArgs) => { Logger.LogError(dataArgs.Data); }; + _hostProcess.OutputDataReceived += (sender, dataArgs) => { Logger.LogInformation(dataArgs.Data); }; _hostProcess.EnableRaisingEvents = true; var hostExitTokenSource = new CancellationTokenSource(); _hostProcess.Exited += (sender, e) =>