void ReportAllErrorsButLastToConsole() { var errors = Errors.ToList(); RemoveLastItem(errors); errors.ForEach(error => consoleMonitor.ReportError(error.Message, error.Exception)); }
async Task <bool> InstallNuGetPackagesAsync(OutputProgressMonitor progressMonitor) { progressMonitor.Console.Debug(0, "", GettextCatalog.GetString("Checking if needed NuGet packages are already installed...\n")); var refsToAdd = new List <PackageManagementPackageReference> (); var installedPackages = PackageManagementServices.ProjectOperations.GetInstalledPackages(project); var packagesToInstall = await GetPackagesToInstallAsync(); foreach (var dep in packagesToInstall) { if (installedPackages.FirstOrDefault(x => x.Id.Equals(dep.PackageId, StringComparison.Ordinal)) == null) { refsToAdd.Add(new PackageManagementPackageReference(dep.PackageId, dep.MaxVersion)); } } if (refsToAdd.Count > 0) { await progressMonitor.Console.Log.WriteLineAsync($"Adding needed NuGet packages ({string.Join (", ", refsToAdd.Select (x => x.Id))})"); try { await PackageManagementServices.ProjectOperations.InstallPackagesAsync(project, refsToAdd, licensesAccepted : true) .ConfigureAwait(false); } catch (Exception ex) { progressMonitor.ReportError($"Failed adding packages: {ex.Message}", ex); return(false); } } return(true); }
async Task <bool> InstallNuGetPackagesAsync(OutputProgressMonitor progressMonitor) { progressMonitor.Console.Debug(0, "", "Checking if needed NuGet packages are already installed...\n"); var refsToAdd = new List <PackageManagementPackageReference> (); var installedPackages = PackageManagementServices.ProjectOperations.GetInstalledPackages(project); foreach (var dep in new [] { "Microsoft.EntityFrameworkCore.SqlServer", "Microsoft.EntityFrameworkCore.Tools", "Microsoft.Extensions.Logging.Debug", "Microsoft.VisualStudio.Web.CodeGeneration.Design" }) { if (installedPackages.FirstOrDefault(x => x.Id.Equals(dep, StringComparison.Ordinal)) == null) { refsToAdd.Add(new PackageManagementPackageReference(dep, null)); } } if (refsToAdd.Count > 0) { await progressMonitor.Console.Log.WriteLineAsync($"Adding needed NuGet packages ({string.Join (", ", refsToAdd.Select (x => x.Id))})"); try { await PackageManagementServices.ProjectOperations.InstallPackagesAsync(project, refsToAdd, licensesAccepted : true) .ConfigureAwait(false); } catch (Exception ex) { progressMonitor.ReportError($"Failed adding packages: {ex.Message}", ex); return(false); } } return(true); }
async Task <bool> InstallDotNetToolAsync(OutputProgressMonitor progressMonitor) { if (!DotNetCoreGlobalToolManager.IsInstalled(toolName)) { if (!await DotNetCoreGlobalToolManager.Install(toolName, progressMonitor.CancellationToken)) { progressMonitor.ReportError($"Could not install {toolName} tool"); return(false); } } return(true); }