private async Task<bool> EnsureCookiecutterIsInstalled() { if (await _cutterClient.IsCookiecutterInstalled()) { return true; } IsInstalling = true; IsInstallingSuccess = false; IsInstallingError = false; try { _outputWindow.WriteLine(string.Format(CultureInfo.CurrentUICulture, Strings.InstallingCookiecutterStarted)); var result = await _cutterClient.CreateCookiecutterEnv(); _outputWindow.WriteLine(string.Join(Environment.NewLine, result.StandardOutputLines)); _outputWindow.WriteErrorLine(string.Join(Environment.NewLine, result.StandardErrorLines)); result = await _cutterClient.InstallPackage(); _outputWindow.WriteLine(string.Join(Environment.NewLine, result.StandardOutputLines)); _outputWindow.WriteErrorLine(string.Join(Environment.NewLine, result.StandardErrorLines)); _outputWindow.WriteLine(string.Empty); _outputWindow.WriteLine(string.Format(CultureInfo.CurrentUICulture, Strings.InstallingCookiecutterSuccess)); _outputWindow.ShowAndActivate(); IsInstalling = false; IsInstallingSuccess = true; IsInstallingError = false; return true; } catch (ProcessException ex) { IsInstalling = false; IsInstallingSuccess = false; IsInstallingError = true; _outputWindow.WriteLine(string.Format(CultureInfo.CurrentUICulture, Strings.ProcessExitCodeMessage, ex.Result.ExeFileName, ex.Result.ExitCode)); _outputWindow.WriteLine(string.Join(Environment.NewLine, ex.Result.StandardOutputLines)); _outputWindow.WriteErrorLine(string.Join(Environment.NewLine, ex.Result.StandardErrorLines)); _outputWindow.WriteLine(string.Empty); _outputWindow.WriteLine(string.Format(CultureInfo.CurrentUICulture, Strings.InstallingCookiecutterFailed)); _outputWindow.ShowAndActivate(); return false; } catch (Exception ex) when (!ex.IsCriticalException()) { IsInstalling = false; IsInstallingSuccess = false; IsInstallingError = true; _outputWindow.WriteErrorLine(ex.Message); _outputWindow.WriteLine(string.Empty); _outputWindow.WriteLine(string.Format(CultureInfo.CurrentUICulture, Strings.InstallingCookiecutterFailed)); _outputWindow.ShowAndActivate(); return false; } }
private async Task <bool> EnsureCookiecutterIsInstalledAsync() { if (await _cutterClient.IsCookiecutterInstalled()) { return(true); } ResetStatus(); InstallingStatus = OperationStatus.InProgress; try { _outputWindow.ShowAndActivate(); _outputWindow.WriteLine(Strings.InstallingCookiecutterStarted); await _cutterClient.CreateCookiecutterEnv(); await _cutterClient.InstallPackage(); _outputWindow.WriteLine(Strings.InstallingCookiecutterSuccess); InstallingStatus = OperationStatus.Succeeded; ReportEvent(CookiecutterTelemetry.TelemetryArea.Prereqs, CookiecutterTelemetry.PrereqsEvents.Install, true.ToString()); return(true); } catch (Exception ex) when(!ex.IsCriticalException()) { InstallingStatus = OperationStatus.Failed; _outputWindow.WriteErrorLine(ex.Message); _outputWindow.WriteLine(Strings.InstallingCookiecutterFailed); ReportEvent(CookiecutterTelemetry.TelemetryArea.Prereqs, CookiecutterTelemetry.PrereqsEvents.Install, false.ToString()); return(false); } }