diff --git a/src/dotnet-scaffolding/Microsoft.DotNet.Scaffolding.Internal/CliHelpers/DotnetCliRunner.cs b/src/dotnet-scaffolding/Microsoft.DotNet.Scaffolding.Internal/CliHelpers/DotnetCliRunner.cs index 0b74e1c6..53e7ae6e 100644 --- a/src/dotnet-scaffolding/Microsoft.DotNet.Scaffolding.Internal/CliHelpers/DotnetCliRunner.cs +++ b/src/dotnet-scaffolding/Microsoft.DotNet.Scaffolding.Internal/CliHelpers/DotnetCliRunner.cs @@ -43,7 +43,16 @@ internal class DotnetCliRunner } }; - process.Start(); + try + { + process.Start(); + } + catch (Exception e) + { + stdErrCallback(e.Message); + return -1; + } + process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); @@ -66,7 +75,16 @@ internal class DotnetCliRunner process.EnableRaisingEvents = true; - process.Start(); + try + { + process.Start(); + } + catch (Exception e) + { + stdOut = string.Empty; + stdErr = e.Message; + return -1; + } var taskOut = outStream.BeginRead(process.StandardOutput); var taskErr = errStream.BeginRead(process.StandardError);