コード例 #1
0
        public void Test(string vs1, string vs2, bool result)
        {
            IVersionSpec ivs1 = GetVersionSpec(vs1);
            IVersionSpec ivs2 = GetVersionSpec(vs2);

            var vsec = new VersionSpecEqualityComparer(ivs1);

            Assert.IsTrue(vsec.Equals(ivs2) == result);
        }
コード例 #2
0
        public void Test(string vs1, string vs2, bool result)
        {
            IVersionSpec ivs1 = GetVersionSpec(vs1);
            IVersionSpec ivs2 = GetVersionSpec(vs2);

            var vsec = new VersionSpecEqualityComparer(ivs1);

            Assert.IsTrue(vsec.Equals(ivs2) == result);
        }
コード例 #3
0
        /// <summary>
        /// Resolves the installable version.
        /// </summary>
        /// <param name="remoteRepository"> </param>
        /// <param name="packageReference"> </param>
        /// <returns></returns>
        public IPackage ResolveLatestInstallablePackage(IPackageRepository remoteRepository, PackageReference packageReference)
        {
            IPackage package = null;

            if (Latest)
            {
                //We can only work on an AggregateRepository, just return null if we dont get one.
                var aggregateRepository = remoteRepository as AggregateRepository;
                if (aggregateRepository == null)
                {
                    return(null);
                }

                var versionSpecComparer = new VersionSpecEqualityComparer(packageReference.VersionConstraint);
                var defaultVersionSpec  = new VersionSpec();

                if (versionSpecComparer.Equals(defaultVersionSpec))
                {
                    //First, check to see if we have already checked for this ID, and if so, return the right version
                    if (_cache.TryCacheHitByIsLatest(packageReference.Id, out package))
                    {
                        return(package);
                    }

                    //TODO need to check where we need to get the bools for this call....assuming a bit much here.
                    Console.Log(MessageLevel.Info, "Checking for latest package: {0}", packageReference.Id);


                    try
                    {
                        IPackage p = aggregateRepository.FindLatestPackage(packageReference.Id);
                        if (p != null)
                        {
                            Console.Log(MessageLevel.Info, "Using latest version : {0} {1}", p.Id, p.ToString());
                            //Only add if there is no constraint....
                            _cache.AddCacheEntryByIsLatest(p);
                            package = p;
                        }
                        else
                        {
                            Console.Log(MessageLevel.Info,
                                        "Latest version requested, however {0} cannot be found on feed.",
                                        packageReference.Id);
                            return(null);
                        }
                    }
                    catch (NullReferenceException)
                    {
                        Console.Log(MessageLevel.Error,
                                    "One of the feeds threw an error, a package called {0} could not be found.",
                                    packageReference.Id);
                        return(null);
                    }
                }

                else
                {
                    Console.Log(MessageLevel.Info, "Checking for latest package: {0} using constraint {1}",
                                packageReference.Id, packageReference.VersionConstraint);
                    if (_cache.TryCacheHitByVersionConstraint(packageReference, out package))
                    {
                        return(package);
                    }

                    try
                    {
                        IPackage p = aggregateRepository.FindLatestPackage(packageReference.Id,
                                                                           packageReference.VersionConstraint);
                        if (p != null)
                        {
                            package = p;
                            _cache.AddCacheEntryByConstraint(package, packageReference.VersionConstraint);
                            Console.Log(MessageLevel.Info, "Using constrained version : {0} {1}, constrained by {2}",
                                        packageReference.Id, p.Version.ToString(), packageReference.VersionConstraint);
                        }
                        else
                        {
                            Console.Log(MessageLevel.Error,
                                        "Latest version requested, however {0} cannot be satisfied on feed using constraint {1}.",
                                        packageReference.Id, packageReference.VersionConstraint);
                            return(null);
                        }
                    }
                    catch (NullReferenceException)
                    {
                        Console.Log(MessageLevel.Error,
                                    "One of the feeds threw an error, a package called {0} could not be found.",
                                    packageReference.Id);
                        return(null);
                    }
                }
            }
            return(package);
        }
コード例 #4
0
        /// <summary>
        /// Resolves the installable version.
        /// </summary>
        /// <param name="remoteRepository"> </param>
        /// <param name="packageReference"> </param>
        /// <returns></returns>
        public IPackage ResolveLatestInstallablePackage(IPackageRepository remoteRepository, PackageReference packageReference)
        {
            IPackage package = null;
            if (Latest)
            {
                //We can only work on an AggregateRepository, just return null if we dont get one.
                var aggregateRepository = remoteRepository as AggregateRepository;
                if (aggregateRepository == null) return null;

                var versionSpecComparer = new VersionSpecEqualityComparer(packageReference.VersionConstraint);
                var defaultVersionSpec = new VersionSpec();

                if (versionSpecComparer.Equals(defaultVersionSpec))
                {
                    //First, check to see if we have already checked for this ID, and if so, return the right version
                    if (_cache.TryCacheHitByIsLatest(packageReference.Id, out package)) return package;

                    //TODO need to check where we need to get the bools for this call....assuming a bit much here.
                    Console.Log(MessageLevel.Info, "Checking for latest package: {0}", packageReference.Id);


                    try
                    {
                        IPackage p = aggregateRepository.FindLatestPackage(packageReference.Id);
                        if (p != null)
                        {
                            Console.Log(MessageLevel.Info, "Using latest version : {0} {1}", p.Id, p.ToString());
                            //Only add if there is no constraint....
                            _cache.AddCacheEntryByIsLatest(p);
                            package = p;
                        }
                        else
                        {
                            Console.Log(MessageLevel.Info,
                                        "Latest version requested, however {0} cannot be found on feed.",
                                        packageReference.Id);
                            return null;
                        }
                    }
                    catch (NullReferenceException)
                    {
                        Console.Log(MessageLevel.Error,
                                    "One of the feeds threw an error, a package called {0} could not be found.",
                                    packageReference.Id);
                        return null;
                    }
                }

                else
                {
                    Console.Log(MessageLevel.Info, "Checking for latest package: {0} using constraint {1}",
                                packageReference.Id, packageReference.VersionConstraint);
                    if (_cache.TryCacheHitByVersionConstraint(packageReference, out package)) return package;

                    try
                    {
                        IPackage p = aggregateRepository.FindLatestPackage(packageReference.Id,
                                                                           packageReference.VersionConstraint);
                        if (p != null)
                        {
                            package = p;
                            _cache.AddCacheEntryByConstraint(package, packageReference.VersionConstraint);
                            Console.Log(MessageLevel.Info, "Using constrained version : {0} {1}, constrained by {2}",
                                        packageReference.Id, p.Version.ToString(), packageReference.VersionConstraint);
                        }
                        else
                        {
                            Console.Log(MessageLevel.Error,
                                        "Latest version requested, however {0} cannot be satisfied on feed using constraint {1}.",
                                        packageReference.Id, packageReference.VersionConstraint);
                            return null;
                        }
                    }
                    catch (NullReferenceException)
                    {
                        Console.Log(MessageLevel.Error,
                                    "One of the feeds threw an error, a package called {0} could not be found.",
                                    packageReference.Id);
                        return null;
                    }
                }
            }
            return package;
        }