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.
This commit is contained in:
Praburaj 2015-04-20 16:00:47 -07:00
parent 78e9ef2782
commit f3a4cf0ea7
1 changed files with 8 additions and 1 deletions

View File

@ -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) =>