private static void RefreshRuntimeLocations()
 {
     if (isRuntimeLocationsAdded)
     {
         return;
     }
     isRuntimeLocationsAdded = true;
     Locations.AddRange(InstalledRuntime.GetCurrent().Select(x => new SearchLocation(x.FullPath).SearchOnlyLocal()));
 }
Пример #2
0
        public static InstalledRuntime[] Get()
        {
            Process process = new Process();

            process.StartInfo.FileName               = "dotnet";
            process.StartInfo.Arguments              = "--list-runtimes";
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError  = true;
            process.Start();
            string output = process.StandardOutput.ReadToEnd();

            process.WaitForExit();

            return(output.Split('\n').Select(x => InstalledRuntime.Parse(x.Trim())).Where(x => x != null).ToArray());
        }