public async Task PowerCleanAsync(params Project[] projects) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); _outputWindow.Clear(); _statusBarService.StartWorkingAnimation($"{nameof(PowerShellService)} start."); _logger.Verbose($"{nameof(PowerShellService)} start."); int succeeded = 0, failed = 0, skipped = 0, count = 1; try { foreach (var project in projects) { _logger.Information(StartMessage(project, count++)); var projectFolder = project.GetRootFolder(); if (projectFolder != null && !string.IsNullOrWhiteSpace(projectFolder) && DirectoriesExists(projectFolder)) { _powerShell.AddScript(PowerCleanCommand(projectFolder), true); _powerShell.Invoke(); if (_powerShell.HadErrors && _powerShell.Streams.Error.Count > 0) { var exception = PowerShellThrowException(_powerShell.Streams.Error); if (exception != null) { throw exception; } } succeeded++; } else { skipped++; } } } catch (Exception e) { failed++; _logger.Error(e, $"{nameof(PowerShellService)} failed with exception: {{exception}}"); } finally { _logger.Information(EndMessage(succeeded, failed, skipped)); _statusBarService.EndWorkingAnimation($"{nameof(PowerShellService)} finished."); } }