public override async Task <Diagonosis> Examine(PatientHistory history) { var vsinfo = await GetWindowsInfo(); var sentinelFiles = new List <string>(); foreach (var vi in vsinfo) { if (vi.Version.IsCompatible(MinimumVersion, ExactVersion)) { ReportStatus($"{vi.Version} - {vi.Path}", Status.Ok); var sentinel = Path.Combine(vi.Path, "MSBuild\\Current\\Bin\\SdkResolvers\\Microsoft.DotNet.MSBuildSdkResolver\\EnableWorkloadResolver.sentinel"); sentinelFiles.Add(sentinel); } else { ReportStatus($"{vi.Version}", null); } } if (sentinelFiles.Any()) { history.AddNotes(this, "sentinel_files", sentinelFiles.ToArray()); } if (vsinfo.Any(vs => vs.Version.IsCompatible(MinimumVersion, ExactVersion))) { return(Diagonosis.Ok(this)); } return(new Diagonosis(Status.Error, this)); }
public override async Task <Diagonosis> Examine(PatientHistory history) { var installedWorkloads = workloadManager.GetInstalledWorkloads(); var missingWorkloads = new List <Manifest.DotNetWorkload>(); var requiredPacks = new List <WorkloadResolver.PackInfo>(); foreach (var rp in RequiredWorkloads) { if (!installedWorkloads.Any(sp => sp == rp.Id)) { ReportStatus($"{rp.Id} not installed.", Status.Error); missingWorkloads.Add(rp); } else { ReportStatus($"{rp.Id} installed.", Status.Ok); var workloadPacks = workloadManager.GetPacksInWorkload(rp.Id); if (workloadPacks != null && workloadPacks.Any()) { foreach (var wp in workloadPacks) { if (!(rp.IgnoredPackIds?.Any(ip => ip.Equals(wp.Id, StringComparison.OrdinalIgnoreCase)) ?? false)) { requiredPacks.Add(wp); } } } } } if (requiredPacks.Any()) { history.AddNotes(this, "required_packs", requiredPacks.ToArray()); } if (!missingWorkloads.Any()) { return(Diagonosis.Ok(this)); } return(new Diagonosis( Status.Error, this, new Prescription("Install Missing SDK Workloads", new DotNetWorkloadInstallRemedy(SdkRoot, SdkVersion, missingWorkloads.ToArray(), NuGetPackageSources)))); }
public override async Task <Diagonosis> Examine(PatientHistory history) { var dn = new DotNet(); var missingDiagnosis = new Diagonosis(Status.Error, this, new Prescription(".NET SDK not installed")); if (!dn.Exists) { return(missingDiagnosis); } var sdks = await dn.GetSdks(); var missingSdks = new List <Manifest.DotNetSdk>(); var sentinelFiles = new List <string>(); if (RequiredSdks?.Any() ?? false) { foreach (var rs in RequiredSdks) { if (!sdks.Any(s => s.Version.Equals(NuGetVersion.Parse(rs.Version)))) { missingSdks.Add(rs); } } } DotNetSdkInfo bestSdk = null; foreach (var sdk in sdks) { var requiredSdk = RequiredSdks.FirstOrDefault(rs => sdk.Version == NuGetVersion.Parse(rs.Version)); if (requiredSdk != null) { if (bestSdk == null || sdk.Version > bestSdk.Version) { bestSdk = sdk; } if (requiredSdk.EnableWorkloadResolver) { var sentinelPath = Path.Combine(sdk.Directory.FullName, "EnableWorkloadResolver.sentinel"); sentinelFiles.Add(sentinelPath); } ReportStatus($"{sdk.Version} - {sdk.Directory}", Status.Ok); } else { ReportStatus($"{sdk.Version} - {sdk.Directory}", null); } } // Find newest compatible sdk if (bestSdk != null) { Util.SetDoctorEnvironmentVariable("DOTNET_SDK", bestSdk.Directory.FullName); } // Add sentinel files that should be considered if (sentinelFiles.Any()) { history.AddNotes(this, "sentinel_files", sentinelFiles.ToArray()); } if (missingSdks.Any()) { var str = SdkListToString(); return(new Diagonosis(Status.Error, this, $".NET SDK {str} not installed.", new Prescription($"Download .NET SDK {str}", new BootsRemedy(missingSdks.Select(ms => (ms.Urls.For(Util.Platform)?.ToString(), ".NET SDK " + ms.Version)).ToArray()) { AdminRequirements = new [] { (Platform.Windows, true) }