public override Task <Diagonosis> Examine(PatientHistory history) { var files = new List <string>(); var contributingCheckupIds = new[] { "dotnet", "visualstudio" }; foreach (var checkupId in contributingCheckupIds) { if (history.TryGetNotes <string[]>(checkupId, "sentinel_files", out var dotnetSentinelFiles) && (dotnetSentinelFiles?.Any() ?? false)) { files.AddRange(dotnetSentinelFiles); } } var missingFiles = new List <string>(); foreach (var file in files.Distinct()) { // Check if exists if (!File.Exists(file)) { missingFiles.Add(file); } } if (missingFiles.Any()) { return(Task.FromResult( new Diagonosis(Status.Error, this, new Prescription("Create EnableWorkloadResolver.sentinel files.", missingFiles.Select(f => new CreateFileRemedy(f)).ToArray())))); } return(Task.FromResult(Diagonosis.Ok(this))); }
public override async Task <Diagonosis> Examine(PatientHistory history) { var sdkPacks = workloadManager.GetAllInstalledWorkloadPacks(); var missingPacks = new List <NuGetPackage>(); var requiredPacks = new List <NuGetPackage>(); requiredPacks.AddRange(RequiredPacks); if (history.TryGetNotes <WorkloadResolver.PackInfo[]>("dotnetworkloads", "required_packs", out var p) && p.Any()) { requiredPacks.AddRange(p.Select(pi => new NuGetPackage { Id = pi.Id, Version = pi.Version })); } var uniqueRequiredPacks = requiredPacks .GroupBy(p => p.Id + p.Version.ToString()) .Select(g => g.First()); foreach (var rp in uniqueRequiredPacks) { if (!sdkPacks.Any(sp => sp.Id == rp.Id && sp.Version == rp.Version)) { ReportStatus($"{rp.Id} ({rp.Version}) not installed.", Status.Warning); missingPacks.Add(rp); } else { ReportStatus($"{rp.Id} ({rp.Version}) installed.", Status.Ok); } } if (!missingPacks.Any()) { return(Diagonosis.Ok(this)); } return(new Diagonosis( Status.Error, this, new Prescription("Install Missing SDK Packs", new DotNetPackInstallRemedy(SdkRoot, SdkVersion, missingPacks.ToArray(), NuGetPackageSources))));; }