diff --git a/Conan.VisualStudio/Services/ConanService.cs b/Conan.VisualStudio/Services/ConanService.cs index 9947f34d..1b474459 100644 --- a/Conan.VisualStudio/Services/ConanService.cs +++ b/Conan.VisualStudio/Services/ConanService.cs @@ -147,41 +147,53 @@ private async Task InstallDependenciesAsync(ConanRunner conan, ConanProject proj Logger.Log(message); await logStream.WriteLineAsync(message); - using (Process exeProcess = Process.Start(process)) + try { - int exitCode = await exeProcess.WaitForExitAsync(); - - var tokenSource = new CancellationTokenSource(); - var token = tokenSource.Token; - - Task outputReader = Task.Factory.StartNew(AppendLinesFunc, - Tuple.Create(logStream, exeProcess.StandardOutput), - token, TaskCreationOptions.None, TaskScheduler.Default); - Task errorReader = Task.Factory.StartNew(AppendLinesFunc, - Tuple.Create(logStream, exeProcess.StandardError), - token, TaskCreationOptions.None, TaskScheduler.Default); - - Task.WaitAll(outputReader, errorReader); - - if (exitCode != 0) { - message = $"Conan has returned exit code '{exitCode}' " + - $"while processing configuration '{configuration}'. " + - $"Please check file '{logFilePath}' for details."; - - Logger.Log(message); - await logStream.WriteLineAsync(message); - _errorListService.WriteError(message, logFilePath); - return; - } - else + using (Process exeProcess = Process.Start(process)) { - message = $"[Conan.VisualStudio] Conan has succsessfully " + - $"installed configuration '{configuration}'"; - Logger.Log(message); - await logStream.WriteLineAsync(message); - _errorListService.WriteMessage(message); + int exitCode = await exeProcess.WaitForExitAsync(); + + string output = await exeProcess.StandardOutput.ReadToEndAsync(); + string error = await exeProcess.StandardError.ReadToEndAsync(); + + if (output.Length > 0) + { + Logger.Log(output); + await logStream.WriteLineAsync(output); + } + + if (error.Length > 0) + { + Logger.Log(error); + await logStream.WriteLineAsync(error); + } + + if (exitCode != 0) + { + message = $"Conan has returned exit code '{exitCode}' " + + $"while processing configuration '{configuration}'. " + + $"Please check file '{logFilePath}' for details."; + + Logger.Log(message); + await logStream.WriteLineAsync(message); + _errorListService.WriteError(message, logFilePath); + return; + } + else + { + message = $"[Conan.VisualStudio] Conan has succsessfully " + + $"installed configuration '{configuration}'"; + Logger.Log(message); + await logStream.WriteLineAsync(message); + _errorListService.WriteMessage(message); + } } } + catch(System.ComponentModel.Win32Exception) + { + message = $"Error running '{process.FileName}'. Is it a valid path to conan.exe?"; + _errorListService.WriteError(message); + } } } }