예제 #1
0
        private IReadOnlyList <PlatformVersion> GetCoreVersions(string dotnetPath)
        {
            const string frameworkName = "Microsoft.NETCore.App";

            var path = Path.Combine(dotnetPath, "shared", frameworkName);

            var sortedDictionary = new SortedDictionary <NuGetVersion, PlatformVersion>();

            foreach (var directory in IOUtilities.EnumerateDirectories(path))
            {
                var versionName = Path.GetFileName(directory);
                if (NuGetVersion.TryParse(versionName, out var version) && version.Major > 1)
                {
                    sortedDictionary.Add(version, new PlatformVersion($"netcoreapp{version.Major}.{version.Minor}", frameworkName, versionName));
                }
            }

            return(sortedDictionary.Values.Reverse().ToImmutableArray());
        }
예제 #2
0
        private (IReadOnlyList <(string tfm, string name)> versions, string dotnetExe) GetCoreVersions()
        {
            var(dotnetExe, sdkPath) = FindNetCore();

            if (!string.IsNullOrEmpty(dotnetExe))
            {
                var dictionary = new Dictionary <NuGetVersion, (string tfm, string name)>();

                foreach (var directory in IOUtilities.EnumerateDirectories(sdkPath))
                {
                    var versionName = Path.GetFileName(directory);
                    if (NuGetVersion.TryParse(versionName, out var version) && version.Major > 1)
                    {
                        dictionary.Add(version, ($"netcoreapp{version.Major}.{version.Minor}", versionName));
                    }
                }

                return(dictionary.OrderBy(c => c.Key.IsPrerelease).ThenByDescending(c => c.Key).Select(c => c.Value).ToImmutableArray(),
                       dotnetExe);
            }

            return(ImmutableArray <(string, string)> .Empty, string.Empty);
        }