protected override void ExecuteCore() { if (MissingWorkloadPacks.Any()) { var workloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(NetCoreRoot, NETCoreSdkVersion); var workloadResolver = WorkloadResolver.Create(workloadManifestProvider, NetCoreRoot, NETCoreSdkVersion); var suggestedWorkloads = workloadResolver.GetWorkloadSuggestionForMissingPacks(MissingWorkloadPacks.Select(item => item.ItemSpec).ToList()); if (GenerateErrorsForMissingWorkloads) { var suggestedInstallCommand = "dotnet workload install " + string.Join(" ", suggestedWorkloads.Select(w => w.Id)); var errorMessage = string.Format(CultureInfo.CurrentCulture, Strings.WorkloadNotInstalled, string.Join(" ", suggestedWorkloads.Select(w => w.Id)), suggestedInstallCommand); Log.LogError(errorMessage); } SuggestedWorkloads = suggestedWorkloads.Select(suggestedWorkload => { var taskItem = new TaskItem(suggestedWorkload.Id); taskItem.SetMetadata("VisualStudioComponentId", ToSafeId(suggestedWorkload.Id)); return(taskItem); }).ToArray(); } }
protected override void ExecuteCore() { if (MissingWorkloadPacks.Any()) { string?userProfileDir = CliFolderPathCalculatorCore.GetDotnetUserProfileFolderPath(); var workloadManifestProvider = new SdkDirectoryWorkloadManifestProvider(NetCoreRoot, NETCoreSdkVersion, userProfileDir); var workloadResolver = WorkloadResolver.Create(workloadManifestProvider, NetCoreRoot, NETCoreSdkVersion, userProfileDir); var suggestedWorkloads = workloadResolver.GetWorkloadSuggestionForMissingPacks( MissingWorkloadPacks.Select(item => new WorkloadPackId(item.ItemSpec)).ToList(), out ISet <WorkloadPackId> unsatisfiablePacks ); if (GenerateErrorsForMissingWorkloads) { if (suggestedWorkloads is not null) { var suggestedInstallCommand = "dotnet workload install " + string.Join(" ", suggestedWorkloads.Select(w => w.Id)); var errorMessage = string.Format(CultureInfo.CurrentCulture, Strings.WorkloadNotInstalled, string.Join(" ", suggestedWorkloads.Select(w => w.Id)), suggestedInstallCommand); Log.LogError(errorMessage); } else { Log.LogError(Strings.WorkloadNotAvailable, string.Join(" ", unsatisfiablePacks)); } } if (suggestedWorkloads is not null) { SuggestedWorkloads = suggestedWorkloads.Select(suggestedWorkload => { var suggestedWorkloadsList = GetSuggestedWorkloadsList(suggestedWorkload); var taskItem = new TaskItem(suggestedWorkload.Id); taskItem.SetMetadata("VisualStudioComponentId", ToSafeId(suggestedWorkload.Id)); taskItem.SetMetadata("VisualStudioComponentIds", string.Join(";", suggestedWorkloadsList)); return(taskItem); }).ToArray(); } } }