Пример #1
0
        public IEnumerable <INugetResolverData> Resolve(
            AssemblyName assemblyName,
            IEnumerable <DirectoryInfo> cacheDirs,
            RuntimeInfo current,
            VersionMatchingStrategies assemblyMatchingStrategy,
            VersionMatchingStrategies packageMatchingStrategy)
        {
            List <INugetResolverData> files = new List <INugetResolverData>();

            if (RuntimesHelper.TryGetLoadableRuntimes(current, out IEnumerable <RuntimeInfo> validRuntimes))
            {
                cacheDirs.Foreach(cache => files.AddRange(GetAssemblyCandidatesFromCache(assemblyName, cache, validRuntimes, assemblyMatchingStrategy, packageMatchingStrategy)));
            }

            return(files
                   .OrderByDescending(d => d.PackageVersion)
                   .ThenByDescending(d => d.PackageTargetFramework, new RuntimeInfoFeatureComparer()));
        }
        internal static List <FileInfo> GetAssemblyCandidates(AssemblyName assemblyName, List <DirectoryInfo> nugetCaches, RuntimeInfo current)
        {
            var candidates = new List <FileInfo>();

            if (RuntimesHelper.TryGetLoadableRuntimes(current, out IEnumerable <RuntimeInfo> validRuntimes))
            {
                foreach (var cache in nugetCaches)
                {
                    candidates.AddRange(GetAssemblyCandidatesFromCache(assemblyName, cache, validRuntimes, true));
                }

                if (!candidates.Any())
                {
                    foreach (var cache in nugetCaches)
                    {
                        candidates.AddRange(GetAssemblyCandidatesFromCache(assemblyName, cache, validRuntimes, false));
                    }
                }
            }

            return(candidates);
        }