private Task <CreationResultStatus> EnterInstallFlowAsync() { Installer.InstallPackages(Install.ToList()); //TODO: When an installer that directly calls into NuGet is available, // return a more accurate representation of the outcome of the operation return(Task.FromResult(CreationResultStatus.Success)); }
private CreationResultStatus EnterInstallFlow() { _telemetryLogger.TrackEvent(CommandName + TelemetryConstants.InstallEventSuffix, new Dictionary <string, string> { { TelemetryConstants.ToInstallCount, _commandInput.ToInstallList.Count.ToString() } }); Installer.InstallPackages(_commandInput.ToInstallList); //TODO: When an installer that directly calls into NuGet is available, // return a more accurate representation of the outcome of the operation return(CreationResultStatus.Success); }
private CreationResultStatus EnterInstallFlow() { _telemetryLogger.TrackEvent(CommandName + TelemetryConstants.InstallEventSuffix, new Dictionary <string, string> { { TelemetryConstants.ToInstallCount, _commandInput.ToInstallList.Count.ToString() } }); bool allowDevInstall = _commandInput.HasDebuggingFlag("--dev:install"); Installer.InstallPackages(_commandInput.ToInstallList, _commandInput.InstallNuGetSourceList, allowDevInstall, _commandInput.IsInteractiveFlagSpecified); //TODO: When an installer that directly calls into NuGet is available, // return a more accurate representation of the outcome of the operation return(CreationResultStatus.Success); }
private bool SyncOptionalWorkloads() { bool isHiveUpdated = false; bool isCustomHive = _commandInput.HasDebuggingFlag("--debug:ephemeral-hive") || _commandInput.HasDebuggingFlag("--debug:custom-hive"); if (!isCustomHive) { string sdkVersion = EnvironmentSettings.Host.Version.Substring(1); // Host.Version (from SDK) has a leading "v" that need to remove. try { List <InstallationRequest> owInstallationRequests = new List <InstallationRequest>(); Dictionary <string, string> owInstalledPkgs = new Dictionary <string, string>(); // packageId -> packageVersion HashSet <string> owSyncRequestsPackageIds = new HashSet <string>(); TemplateLocator optionalWorkloadLocator = new TemplateLocator(); string dotnetPath = Path.GetDirectoryName(Path.GetDirectoryName(_paths.Global.BaseDir)); IReadOnlyCollection <IOptionalSdkTemplatePackageInfo> owPkgsToSync = optionalWorkloadLocator.GetDotnetSdkTemplatePackages(sdkVersion, dotnetPath); foreach (IInstallUnitDescriptor descriptor in _settingsLoader.InstallUnitDescriptorCache.Descriptors.Values) { if (descriptor.IsPartOfAnOptionalWorkload) { if (!descriptor.Details.TryGetValue("Version", out string pkgVersion)) { pkgVersion = string.Empty; } owInstalledPkgs.Add(descriptor.Identifier, pkgVersion); } } foreach (IOptionalSdkTemplatePackageInfo packageInfo in owPkgsToSync) { owSyncRequestsPackageIds.Add(packageInfo.TemplatePackageId); if (!owInstalledPkgs.TryGetValue(packageInfo.TemplatePackageId, out string version) || version != packageInfo.TemplateVersion) { isHiveUpdated = true; owInstallationRequests.Add(new InstallationRequest(packageInfo.Path, isPartOfAnOptionalWorkload: true)); } } if (owInstallationRequests.Count != 0) { Installer.InstallPackages(owInstallationRequests); } // remove uninstalled Optional SDK Workload packages List <string> owRemovalRequestsPackageIds = new List <string>(); foreach (string descriptorIdentifier in owInstalledPkgs.Keys) { if (!owSyncRequestsPackageIds.Contains(descriptorIdentifier)) { owRemovalRequestsPackageIds.Add(descriptorIdentifier); } } if (owRemovalRequestsPackageIds.Count != 0) { isHiveUpdated = true; IEnumerable <string> failures = Installer.Uninstall(owRemovalRequestsPackageIds); foreach (string failure in failures) { Reporter.Output.WriteLine(string.Format(LocalizableStrings.CouldntUninstall, failure)); } } } catch (Exception ex) { throw new HiveSynchronizationException(LocalizableStrings.OptionalWorkloadsSyncFailed, sdkVersion, ex); } } return(isHiveUpdated); }
// TODO: make sure help / usage works right in these cases. private CreationResultStatus EnterMaintenanceFlow() { if (!TemplateListResolver.ValidateRemainingParameters(_commandInput, out IReadOnlyList <string> invalidParams)) { HelpForTemplateResolution.DisplayInvalidParameters(invalidParams); if (_commandInput.IsHelpFlagSpecified) { _telemetryLogger.TrackEvent(CommandName + "-Help"); HelpForTemplateResolution.ShowUsageHelp(_commandInput); } else { Reporter.Error.WriteLine(string.Format(LocalizableStrings.RunHelpForInformationAboutAcceptedParameters, CommandName).Bold().Red()); } return(CreationResultStatus.InvalidParamValues); } if (_commandInput.ToInstallList != null && _commandInput.ToInstallList.Count > 0 && _commandInput.ToInstallList[0] != null) { Installer.InstallPackages(_commandInput.ToInstallList.Select(x => x.Split(new[] { "::" }, StringSplitOptions.None)[0])); } if (_commandInput.ToUninstallList != null) { if (_commandInput.ToUninstallList.Count > 0 && _commandInput.ToUninstallList[0] != null) { IEnumerable <string> failures = Installer.Uninstall(_commandInput.ToUninstallList); foreach (string failure in failures) { Console.WriteLine(LocalizableStrings.CouldntUninstall, failure); } } else { Console.WriteLine(LocalizableStrings.CommandDescription); Console.WriteLine(); Console.WriteLine(LocalizableStrings.InstalledItems); foreach (string value in _settingsLoader.InstallUnitDescriptorCache.InstalledItems.Values) { Console.WriteLine($" {value}"); } return(CreationResultStatus.Success); } } if (_commandInput.ToInstallList != null && _commandInput.ToInstallList.Count > 0 && _commandInput.ToInstallList[0] != null) { CreationResultStatus installResult = EnterInstallFlow(); if (installResult == CreationResultStatus.Success) { _settingsLoader.Reload(); TemplateListResolutionResult resolutionResult = QueryForTemplateMatches(); HelpForTemplateResolution.CoordinateHelpAndUsageDisplay(resolutionResult, EnvironmentSettings, _commandInput, _hostDataLoader, _telemetryLogger, _templateCreator, _defaultLanguage); } return(installResult); } //No other cases specified, we've fallen through to "Usage help + List" HelpForTemplateResolution.ShowUsageHelp(_commandInput); TemplateListResolutionResult templateResolutionResult = QueryForTemplateMatches(); HelpForTemplateResolution.CoordinateHelpAndUsageDisplay(templateResolutionResult, EnvironmentSettings, _commandInput, _hostDataLoader, _telemetryLogger, _templateCreator, _defaultLanguage); return(CreationResultStatus.Success); }