public override async Task <DiagnosticResult> Examine(SharedState 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.ContributeState(this, "sentinel_files", sentinelFiles.ToArray()); } if (vsinfo.Any(vs => vs.Version.IsCompatible(MinimumVersion, ExactVersion))) { return(DiagnosticResult.Ok(this)); } return(new DiagnosticResult(Status.Error, this)); }
public override Task <DiagnosticResult> Examine(SharedState history) { // Info here: https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#online-only-deployment string WebView2RegistryKey = @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"; var webView2VersionObject = Microsoft.Win32.Registry.GetValue( keyName: WebView2RegistryKey, valueName: "pv", defaultValue: null); var webView2Version = webView2VersionObject as string; var isWebView2Installed = !string.IsNullOrEmpty(webView2Version); if (isWebView2Installed) { ReportStatus($"Found Edge WebView2 version {webView2Version}", Status.Ok); return(Task.FromResult(DiagnosticResult.Ok(this))); } return(Task.FromResult(new DiagnosticResult( Status.Error, this, new Suggestion($"Download Edge WebView2 from https://developer.microsoft.com/microsoft-edge/webview2/")))); }
public override Task <DiagnosticResult> Examine(SharedState history) { var xamJdks = new List <OpenJdkInfo>(); try { var xamSdkInfo = new AndroidSdkInfo((traceLevel, msg) => Util.Log(msg), null, null, null); if (!string.IsNullOrEmpty(xamSdkInfo.JavaSdkPath)) { SearchDirectoryForJdks(xamJdks, xamSdkInfo.JavaSdkPath); } } catch (Exception ex) { Util.Exception(ex); } var jdks = xamJdks.Concat(FindJdks()) .GroupBy(j => j.Directory.FullName) .Select(g => g.First()); var ok = false; foreach (var jdk in jdks) { if ((jdk.JavaC.FullName.Contains("microsoft", StringComparison.OrdinalIgnoreCase) || jdk.JavaC.FullName.Contains("openjdk", StringComparison.OrdinalIgnoreCase)) && jdk.Version.IsCompatible(Version, RequireExact ? Version : null)) { ok = true; ReportStatus($"{jdk.Version} ({jdk.Directory})", Status.Ok); history.SetEnvironmentVariable("JAVA_HOME", jdk.Directory.FullName); // Try and set the global env var on windows if it's not set if (Util.IsWindows && string.IsNullOrEmpty(Environment.GetEnvironmentVariable("JAVA_HOME"))) { try { Environment.SetEnvironmentVariable("JAVA_HOME", jdk.Directory.FullName, EnvironmentVariableTarget.Machine); ReportStatus($"Set Environment Variable: JAVA_HOME={jdk.Directory.FullName}", Status.Ok); } catch { } } } else { ReportStatus($"{jdk.Version} ({jdk.Directory.FullName})", null); } } if (ok) { return(Task.FromResult(DiagnosticResult.Ok(this))); } return(Task.FromResult(new DiagnosticResult(Status.Error, this, new Suggestion("Install OpenJDK11", new BootsSolution(Manifest?.Check?.OpenJdk?.Url, "Download and Install Microsoft OpenJDK 11"))))); }
public override Task <DiagnosticResult> Examine(SharedState history) { var xamJdks = new List <OpenJdkInfo>(); try { var xamSdkInfo = new AndroidSdkInfo((traceLevel, msg) => Util.Log(msg), null, null, null); if (!string.IsNullOrEmpty(xamSdkInfo.JavaSdkPath)) { SearchDirectoryForJdks(xamJdks, xamSdkInfo.JavaSdkPath); } } catch (Exception ex) { Util.Exception(ex); } var jdks = xamJdks.Concat(FindJdks()); var ok = false; foreach (var jdk in jdks) { if ((jdk.JavaC.FullName.Contains("microsoft") || jdk.JavaC.FullName.Contains("openjdk")) && jdk.Version.IsCompatible(MinimumVersion, ExactVersion)) { ok = true; ReportStatus($"{jdk.Version} ({jdk.Directory})", Status.Ok); history.SetEnvironmentVariable("JAVA_HOME", jdk.Directory.FullName); // Try and set the global env var on windows if it's not set if (Util.IsWindows && string.IsNullOrEmpty(Environment.GetEnvironmentVariable("JAVA_HOME"))) { try { Environment.SetEnvironmentVariable("JAVA_HOME", jdk.Directory.FullName, EnvironmentVariableTarget.Machine); ReportStatus($"Set Environemnt Variable: JAVA_HOME={jdk.Directory.FullName}", Status.Ok); } catch { } } } else { ReportStatus($"{jdk.Version} ({jdk.Directory})", null); } } if (ok) { return(Task.FromResult(DiagnosticResult.Ok(this))); } return(Task.FromResult(new DiagnosticResult(Status.Error, this))); }
public override Task <DiagnosticResult> Examine(SharedState history) { var selected = GetSelectedXCode(); if (selected.Version.IsCompatible(MinimumVersion, ExactVersion)) { // Selected version is good ReportStatus($"Xcode.app ({VersionName})", Status.Ok); return(Task.FromResult(DiagnosticResult.Ok(this))); } XCodeInfo eligibleXcode = null; var xcodes = FindXCodeInstalls(); foreach (var x in xcodes) { if (x.Version.IsCompatible(MinimumVersion, ExactVersion)) { eligibleXcode = x; break; } } if (eligibleXcode != null) { // If this is the case, they need to run xcode-select -s ReportStatus($"No Xcode.app or an incompatible Xcode.app version is selected, but one was found at ({eligibleXcode.Path})", Status.Error); return(Task.FromResult(new DiagnosticResult( Status.Error, this, new Suggestion("Run xcode-select -s <Path>", new Solutions.ActionSolution((sln, cancelToken) => { ShellProcessRunner.Run("xcode-select", "-s " + eligibleXcode.Path); return Task.CompletedTask; }))))); } ReportStatus($"Xcode.app ({VersionName}) not installed.", Status.Error); return(Task.FromResult(new DiagnosticResult( Status.Error, this, new Suggestion($"Download XCode {VersionName}")))); }
public override async Task <DiagnosticResult> Examine(SharedState history) { var info = await GetInfo(); if (NuGetVersion.TryParse(info.Version?.ToString(), out var semVer)) { if (semVer.IsCompatible(MinimumVersion, ExactVersion)) { ReportStatus($"XCode.app ({info.Version} {info.Build})", Status.Ok); return(DiagnosticResult.Ok(this)); } } ReportStatus($"XCode.app ({info.Version}) not installed.", Status.Error); return(new DiagnosticResult(Status.Error, this, new Suggestion($"Download XCode {MinimumVersion.ThisOrExact(ExactVersion)}"))); }
public override Task <DiagnosticResult> Examine(SharedState history) { string sdkVersion; if (!history.TryGetEnvironmentVariable("DOTNET_SDK_VERSION", out sdkVersion)) { sdkVersion = SdkVersion; } var workloadManager = new DotNetWorkloadManager(SdkRoot, sdkVersion, NuGetPackageSources); var sdkPacks = workloadManager.GetAllInstalledWorkloadPacks(); var missingPacks = new List <Manifest.DotNetSdkPack>(); foreach (var rp in GetAllRequiredPacks(history)) { Util.Log($"Looking for pack: {rp.Id} ({rp.Version})"); if (!sdkPacks.Any(sp => sp.Id == rp.Id && sp.Version == rp.Version) && !workloadManager.TemplateExistsOnDisk(rp.Id, rp.Version, rp.PackKind, rp.TemplateShortName) && !workloadManager.PackExistsOnDisk(rp.Id, 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(Task.FromResult(DiagnosticResult.Ok(this))); } var remedies = missingPacks .Select(ms => new DotNetPackInstallSolution(SdkRoot, sdkVersion, ms, NuGetPackageSources)); return(Task.FromResult(new DiagnosticResult( Status.Error, this, new Suggestion("Install Missing SDK Packs", remedies.ToArray())))); }
public override async Task<DiagnosticResult> Examine(SharedState history) { var vsinfo = await GetWindowsInfo(); foreach (var vi in vsinfo) { if (vi.Version.IsCompatible(MinimumVersion, ExactVersion)) ReportStatus($"{vi.Version} - {vi.Path}", Status.Ok); else ReportStatus($"{vi.Version}", null); } if (vsinfo.Any(vs => vs.Version.IsCompatible(MinimumVersion, ExactVersion))) return DiagnosticResult.Ok(this); ReportStatus($"Missing Visual Studio >= {MinimumVersion.ThisOrExact(ExactVersion)}", Status.Error); return new DiagnosticResult(Status.Error, this); }
public override Task <DiagnosticResult> Examine(SharedState history) { var dotnet = new DotNetSdk(history); var sdkRoot = dotnet.DotNetSdkLocation.FullName; if (history.TryGetEnvironmentVariable("DOTNET_SDK_VERSION", out var sdkVersion)) { // HACK / WORKAROUND // Workload manifest specs changed between p4/p5 and with that came manifest folder name changes // The problem is we can be left with duplicate workload manifests but in different // folder names and the resolver can't handle that. // This will identify a block list of old workload folders and delete them if the dotnet version // is -preview.5 or newer of the sdk and a different block list if -preview.4 or older if (NuGetVersion.TryParse(sdkVersion, out var parsedSdkVersion)) { DeleteBlockedWorkloads( sdkRoot, $"{parsedSdkVersion.Major}.{parsedSdkVersion.Minor}.{parsedSdkVersion.Patch}", parsedSdkVersion >= new NuGetVersion("6.0.100-preview.5") ? new[] { "Microsoft.NET.Workload.Android", "Microsoft.NET.Workload.BlazorWebAssembly", "Microsoft.NET.Workload.iOS", "Microsoft.NET.Workload.MacCatalyst", "Microsoft.NET.Workload.macOS", "Microsoft.NET.Workload.tvOS" } : new[] { "Microsoft.NET.Sdk.Android", "Microsoft.NET.Sdk.iOS", "Microsoft.NET.Sdk.MacCatalyst", "Microsoft.NET.Sdk.macOS", "Microsoft.NET.Sdk.tvOS", "Microsoft.NET.Workload.Mono.ToolChain" }); } } return(Task.FromResult(DiagnosticResult.Ok(this))); }
public override Task <DiagnosticResult> Examine(SharedState history) { var files = GetAllSentinelFiles(history); var missingFiles = new List <string>(); foreach (var file in files.Distinct()) { // Check if exists if (!File.Exists(file)) { try { File.Create(file); } catch (Exception ex) { Util.Exception(ex); } } if (!file.Contains("omnisharp")) { if (!File.Exists(file)) { ReportStatus(file + " does not exist.", Status.Error); missingFiles.Add(file); } else { ReportStatus(file + " exists.", Status.Ok); } } } if (missingFiles.Any()) { return(Task.FromResult( new DiagnosticResult(Status.Error, this, new Suggestion("Create EnableWorkloadResolver.sentinel files.", missingFiles.Select(f => new CreateFileSolution(f)).ToArray())))); } return(Task.FromResult(DiagnosticResult.Ok(this))); }
public override async Task <DiagnosticResult> Examine(SharedState history) { var vsinfo = await GetWindowsInfo(); foreach (var vi in vsinfo) { if (vi.Version.IsCompatible(MinimumVersion, ExactVersion)) { ReportStatus($"{vi.Version} - {vi.Path}", Status.Ok); } else { ReportStatus($"{vi.Version}", null); } } if (vsinfo.Any(vs => vs.Version.IsCompatible(MinimumVersion, ExactVersion))) { return(DiagnosticResult.Ok(this)); } return(new DiagnosticResult(Status.Error, this)); }
public override async Task <DiagnosticResult> Examine(SharedState history) { var vsinfo = await GetMacInfo(); var ok = false; foreach (var vs in vsinfo) { if (vs.Version.IsCompatible(MinimumVersion, ExactVersion)) { ok = true; ReportStatus($"Visual Studio for Mac ({vs.Version})", Status.Ok); } else { ReportStatus($"Visual Studio for Mac ({vs.Version})", null); } } // Check VSCode sentinel files, ie: // ~/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.8-beta.15/omnisharp/.msbuild/Current/Bin var vscodeExtPath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".vscode", "extensions"); var sentinelFiles = new List <string>(); var vscodeExtDir = new DirectoryInfo(vscodeExtPath); if (vscodeExtDir.Exists) { var sdkResolverDirs = Directory.EnumerateDirectories(vscodeExtPath, "*Microsoft.DotNet.MSBuildSdkResolver", SearchOption.AllDirectories); if (sdkResolverDirs?.Any() ?? false) { foreach (var r in sdkResolverDirs) { if (!Directory.Exists(r)) { continue; } var sentinelFile = Path.Combine(r, "EnableWorkloadResolver.sentinel"); sentinelFiles.Add(sentinelFile); } } } if (sentinelFiles.Any()) { history.ContributeState(this, "sentinel_files", sentinelFiles.ToArray()); } if (ok || Optional) { return(DiagnosticResult.Ok(this)); } return(new DiagnosticResult(Status.Error, this)); }
public override Task <DiagnosticResult> Examine(SharedState history) { var android = new AndroidSdk.AndroidSdkManager( history.GetEnvironmentVariable("ANDROID_SDK_ROOT") ?? history.GetEnvironmentVariable("ANDROID_HOME")); var avds = AndroidSdk.AvdManager.ListAvdsFromFiles(); // android.AvdManager.ListAvds(); // This isn't really helpful anymore as avd cli tools don't seem to work with JDK 11 //if (!avds.Any()) // avds = android.AvdManager.ListAvds(); if (avds.Any()) { var emu = avds.FirstOrDefault(); ReportStatus($"Emulator: {emu.Name ?? emu.SdkId} found.", Status.Ok); return(Task.FromResult(DiagnosticResult.Ok(this))); } // If we got here, there are no emulators at all var missingEmulators = RequiredEmulators; if (!missingEmulators.Any()) { return(Task.FromResult(DiagnosticResult.Ok(this))); } AndroidSdk.AvdManager.AvdDevice preferredDevice = null; try { var devices = android.AvdManager.ListDevices(); preferredDevice = devices.FirstOrDefault(d => d.Name.Contains("pixel", StringComparison.OrdinalIgnoreCase)); } catch (Exception ex) { var msg = "Unable to find any Android Emulators. You can use Visual Studio to create one if necessary: [underline]https://docs.microsoft.com/xamarin/android/get-started/installation/android-emulator/device-manager[/]"; ReportStatus(msg, Status.Warning); Util.Exception(ex); return(Task.FromResult( new DiagnosticResult(Status.Warning, this, msg))); } return(Task.FromResult(new DiagnosticResult( Status.Error, this, new Suggestion("Create an Android Emulator", missingEmulators.Select(me => new ActionSolution(t => { try { var installer = new AndroidSDKInstaller(new Helper(), AndroidManifestType.GoogleV2); installer.Discover(); var sdkInstance = installer.FindInstance(null); var installedPackages = sdkInstance.Components.AllInstalled(true); var sdkPackage = installedPackages.FirstOrDefault(p => p.Path.Equals(me.SdkId, StringComparison.OrdinalIgnoreCase)); if (sdkPackage == null && (me.AlternateSdkIds?.Any() ?? false)) { sdkPackage = installedPackages.FirstOrDefault(p => me.AlternateSdkIds.Any(a => a.Equals(p.Path, StringComparison.OrdinalIgnoreCase))); } var sdkId = sdkPackage?.Path ?? me.SdkId; android.AvdManager.Create($"Android_Emulator_{me.ApiLevel}", sdkId, device: preferredDevice?.Id, tag: "google_apis", force: true, interactive: true); return Task.CompletedTask; } catch (Exception ex) { ReportStatus("Unable to create Emulator. Use Visual Studio to create one instead: https://docs.microsoft.com/xamarin/android/get-started/installation/android-emulator/device-manager", Status.Warning); Util.Exception(ex); } return Task.CompletedTask; })).ToArray())))); }
public override Task <DiagnosticResult> Examine(SharedState history) { var android = new AndroidSdk.AndroidSdkManager( history.GetEnvironmentVariable("ANDROID_SDK_ROOT") ?? history.GetEnvironmentVariable("ANDROID_HOME")); var avds = AndroidSdk.AvdManager.ListAvdsFromFiles(); if (!avds.Any()) { avds = android.AvdManager.ListAvds(); } if (avds.Any()) { var emu = avds.FirstOrDefault(); ReportStatus($"Emulator: {emu.Name ?? emu.SdkId} found.", Status.Ok); return(Task.FromResult(DiagnosticResult.Ok(this))); } var missingEmulators = new List <AndroidEmulator>(); foreach (var emu in RequiredEmulators) { var existingAvd = avds.FirstOrDefault(a => a.SdkId.Equals(emu.SdkId, StringComparison.OrdinalIgnoreCase)); if (existingAvd == null) { missingEmulators.Add(emu); ReportStatus($"{emu.Description ?? emu.SdkId} not created.", Status.Error); } else { ReportStatus($"{emu.Description ?? emu.SdkId} exists.", Status.Ok); } } if (!missingEmulators.Any()) { return(Task.FromResult(DiagnosticResult.Ok(this))); } var devices = android.AvdManager.ListDevices(); var preferredDevice = devices.FirstOrDefault(d => d.Name.Contains("pixel", StringComparison.OrdinalIgnoreCase)); return(Task.FromResult(new DiagnosticResult( Status.Error, this, new Suggestion("Create an Android Emulator", missingEmulators.Select(me => new ActionSolution(t => { var installer = new AndroidSDKInstaller(new Helper(), AndroidManifestType.GoogleV2); installer.Discover(); var sdkInstance = installer.FindInstance(null); var installedPackages = sdkInstance.Components.AllInstalled(true); var sdkPackage = installedPackages.FirstOrDefault(p => p.Path.Equals(me.SdkId, StringComparison.OrdinalIgnoreCase)); if (sdkPackage == null && (me.AlternateSdkIds?.Any() ?? false)) { sdkPackage = installedPackages.FirstOrDefault(p => me.AlternateSdkIds.Any(a => a.Equals(p.Path, StringComparison.OrdinalIgnoreCase))); } var sdkId = sdkPackage?.Path ?? me.SdkId; android.AvdManager.Create($"Android_Emulator_{me.ApiLevel}", sdkId, device: preferredDevice?.Id, tag: "google_apis", force: true, interactive: true); return Task.CompletedTask; })).ToArray())))); }
public override Task <DiagnosticResult> Examine(SharedState history) { var jdkPath = history.GetEnvironmentVariable("JAVA_HOME") ?? Environment.GetEnvironmentVariable("JAVA_HOME"); string androidSdkPath = null; try { // Set the logger to override the default one that is set in this library // So we can catch output from failed path lookups that are otherwise swallowed var _ = new AndroidSdkInfo((traceLevel, msg) => { if (Util.Verbose || traceLevel == System.Diagnostics.TraceLevel.Error) { Util.LogAlways(msg); } }, androidSdkPath, null, jdkPath); } catch (Exception ex) { Util.Exception(ex); } if (string.IsNullOrEmpty(androidSdkPath)) { androidSdkPath = FindBestSdkLocation(); } var missingPackages = new List <IAndroidComponent>(); var installer = new AndroidSDKInstaller(new Helper(), AndroidManifestType.GoogleV2); installer.Discover(new List <string> { androidSdkPath }); var sdkInstance = installer.FindInstance(androidSdkPath); if (string.IsNullOrEmpty(sdkInstance?.Path)) { return(Task.FromResult( new DiagnosticResult( Status.Error, this, "Failed to find Android SDK.", new Suggestion("Install the Android SDK", "For more information see: [underline]https://aka.ms/dotnet-androidsdk-help[/]")))); } history.SetEnvironmentVariable("ANDROID_SDK_ROOT", sdkInstance.Path); history.SetEnvironmentVariable("ANDROID_HOME", sdkInstance.Path); var installed = sdkInstance?.Components?.AllInstalled(true); foreach (var package in RequiredPackages) { var v = !string.IsNullOrWhiteSpace(package.Version) ? new AndroidRevision(package.Version) : null; var installedPkg = FindInstalledPackage(installed, package) ?? FindInstalledPackage(installed, package.Alternatives?.ToArray()); if (installedPkg == null) { var pkgToInstall = sdkInstance?.Components?.AllNotInstalled()? .FirstOrDefault(p => p.Path.Equals(package.Path.Trim(), StringComparison.OrdinalIgnoreCase) && p.Revision >= (v ?? p.Revision)); ReportStatus($"{package.Path} ({package.Version}) missing.", Status.Error); if (pkgToInstall != null) { missingPackages.Add(pkgToInstall); } } else { if (!package.Path.Equals(installedPkg.Path) || v != (installedPkg.Revision ?? installedPkg.InstalledRevision)) { ReportStatus($"{installedPkg.Path} ({installedPkg.InstalledRevision ?? installedPkg.Revision})", Status.Ok); } else { ReportStatus($"{package.Path} ({package.Version})", Status.Ok); } } } if (!missingPackages.Any()) { return(Task.FromResult(DiagnosticResult.Ok(this))); } var installationSet = installer.GetInstallationSet(sdkInstance, missingPackages); var desc = @$ "Your Android SDK has missing or outdated packages. You can use the Android SDK Manager to install / update them. For more information see: [underline]https://aka.ms/dotnet-androidsdk-help[/]";
public override Task <DiagnosticResult> Examine(SharedState history) { AndroidSdk.AvdManager avdManager = null; var javaHome = history.GetEnvironmentVariable("JAVA_HOME"); string java = null; if (!string.IsNullOrEmpty(javaHome) && Directory.Exists(javaHome)) { java = Path.Combine(javaHome, "bin", "java" + (Util.IsWindows ? ".exe" : "")); } var avds = new List <AndroidSdk.AvdManager.Avd>(); // Try invoking the java avdmanager library first if (File.Exists(java)) { avdManager = new AndroidSdk.AvdManager(java, history.GetEnvironmentVariable("ANDROID_SDK_ROOT") ?? history.GetEnvironmentVariable("ANDROID_HOME")); avds.AddRange(avdManager.ListAvds()); } // Fallback to manually reading the avd files if (!avds.Any()) { avds.AddRange(AndroidSdk.AvdManager.ListAvdsFromFiles()); } if (avds.Any()) { var emu = avds.FirstOrDefault(); ReportStatus($"Emulator: {emu.Name ?? emu.SdkId} found.", Status.Ok); return(Task.FromResult(DiagnosticResult.Ok(this))); } // If we got here, there are no emulators at all var missingEmulators = RequiredEmulators; if (!missingEmulators.Any()) { return(Task.FromResult(DiagnosticResult.Ok(this))); } AndroidSdk.AvdManager.AvdDevice preferredDevice = null; try { if (avdManager != null) { var devices = avdManager.ListDevices(); preferredDevice = devices.FirstOrDefault(d => d.Name.Contains("pixel", StringComparison.OrdinalIgnoreCase)); } } catch (Exception ex) { var msg = "Unable to find any Android Emulators. You can use Visual Studio to create one if necessary: [underline]https://docs.microsoft.com/xamarin/android/get-started/installation/android-emulator/device-manager[/]"; ReportStatus(msg, Status.Warning); Util.Exception(ex); return(Task.FromResult( new DiagnosticResult(Status.Warning, this, msg))); } return(Task.FromResult(new DiagnosticResult( Status.Error, this, new Suggestion("Create an Android Emulator", missingEmulators.Select(me => new ActionSolution((sln, cancel) => { try { var installer = new AndroidSDKInstaller(new Helper(), AndroidManifestType.GoogleV2); installer.Discover(); var sdkInstance = installer.FindInstance(null); var installedPackages = sdkInstance.Components.AllInstalled(true); var sdkPackage = installedPackages.FirstOrDefault(p => p.Path.Equals(me.SdkId, StringComparison.OrdinalIgnoreCase)); if (sdkPackage == null && (me.AlternateSdkIds?.Any() ?? false)) { sdkPackage = installedPackages.FirstOrDefault(p => me.AlternateSdkIds.Any(a => a.Equals(p.Path, StringComparison.OrdinalIgnoreCase))); } var sdkId = sdkPackage?.Path ?? me.SdkId; avdManager.Create($"Android_Emulator_{me.ApiLevel}", sdkId, device: preferredDevice?.Id, tag: "google_apis", force: true, interactive: true); return Task.CompletedTask; } catch (Exception ex) { ReportStatus("Unable to create Emulator. Use Visual Studio to create one instead: https://docs.microsoft.com/xamarin/android/get-started/installation/android-emulator/device-manager", Status.Warning); Util.Exception(ex); } return Task.CompletedTask; })).ToArray())))); }
public override Task <DiagnosticResult> Examine(SharedState history) { string sdkVersion; if (!history.TryGetEnvironmentVariable("DOTNET_SDK_VERSION", out sdkVersion)) { sdkVersion = SdkVersion; } var workloadManager = new DotNetWorkloadManager(SdkRoot, sdkVersion, NuGetPackageSources); var installedWorkloads = workloadManager.GetInstalledWorkloads(); var installedPackageWorkloads = workloadManager.GetInstalledWorkloadNuGetPackages(); var missingWorkloads = new List <Manifest.DotNetWorkload>(); var requiredPacks = new List <WorkloadResolver.PackInfo>(); foreach (var rp in RequiredWorkloads) { NuGetVersion rpVersion; if (!NuGetVersion.TryParse(rp.Version, out rpVersion)) { rpVersion = new NuGetVersion(0, 0, 0); } if (!installedPackageWorkloads.Any(sp => sp.packageId.Equals(rp.PackageId, StringComparison.OrdinalIgnoreCase) && sp.packageVersion == rpVersion) || !installedWorkloads.Any(sp => sp.id.Equals(rp.Id, StringComparison.OrdinalIgnoreCase))) { ReportStatus($"{rp.Id} ({rp.PackageId} : {rp.Version}) not installed.", Status.Error); missingWorkloads.Add(rp); } else { ReportStatus($"{rp.Id} ({rp.PackageId} : {rp.Version}) 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.ContributeState(this, "required_packs", requiredPacks.ToArray()); } if (!missingWorkloads.Any()) { return(Task.FromResult(DiagnosticResult.Ok(this))); } var remedies = missingWorkloads .Select(mw => new DotNetWorkloadInstallSolution(SdkRoot, sdkVersion, mw, NuGetPackageSources)); return(Task.FromResult(new DiagnosticResult( Status.Error, this, new Suggestion("Install Missing SDK Workloads", remedies.ToArray())))); }