Task <XCodeInfo> GetInfo() { //Xcode 12.4 //Build version 12D4e var r = ShellProcessRunner.Run("xcodebuild", "-version"); var info = new XCodeInfo(); foreach (var line in r.StandardOutput) { if (line.StartsWith("Xcode")) { var vstr = line.Substring(5).Trim(); if (Version.TryParse(vstr, out var v)) { info.Version = v; } } else if (line.StartsWith("Build version")) { info.Build = line.Substring(13)?.Trim(); } } return(Task.FromResult(info)); }
bool TryGetJavaJdkInfo(string javacFilename, out OpenJdkInfo javaJdkInfo) { var r = ShellProcessRunner.Run(javacFilename, "-version"); var m = rxJavaCVersion.Match(r.GetOutput() ?? string.Empty); var v = m?.Value; if (!string.IsNullOrEmpty(v) && NuGetVersion.TryParse(v, out var version)) { javaJdkInfo = new OpenJdkInfo(javacFilename, version); return(true); } javaJdkInfo = default; return(false); }
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}")))); }
Task<IEnumerable<VisualStudioInfo>> GetWindowsInfo() { var items = new List<VisualStudioInfo>(); var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Microsoft Visual Studio", "Installer", "vswhere.exe"); if (!File.Exists(path)) Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Microsoft Visual Studio", "Installer", "vswhere.exe"); if (!File.Exists(path)) return default; var r = ShellProcessRunner.Run(path, "-all -requires Microsoft.Component.MSBuild -format json -prerelease"); var str = r.GetOutput(); var json = JsonDocument.Parse(str); foreach (var vsjson in json.RootElement.EnumerateArray()) { if (!vsjson.TryGetProperty("catalog", out var vsCat) || !vsCat.TryGetProperty("productSemanticVersion", out var vsSemVer)) continue; if (!NuGetVersion.TryParse(vsSemVer.GetString(), out var semVer)) continue; if (!vsjson.TryGetProperty("installationPath", out var installPath)) continue; items.Add(new VisualStudioInfo { Version = semVer, Path = installPath.GetString() }); } return Task.FromResult<IEnumerable<VisualStudioInfo>>(items); }
XCodeInfo GetSelectedXCode() { var r = ShellProcessRunner.Run("xcode-select", "-p"); var xcodeSelectedPath = r.GetOutput().Trim(); if (!string.IsNullOrEmpty(xcodeSelectedPath)) { if (xcodeSelectedPath.Equals(BugCommandLineToolsPath)) { throw new InvalidDataException(); } var infoPlist = Path.Combine(xcodeSelectedPath, "..", "Info.plist"); if (File.Exists(infoPlist)) { return(GetXcodeInfo( Path.GetFullPath( Path.Combine(xcodeSelectedPath, "..", "..")), true)); } } return(null); }