public static IEnumerable <IPackage> FindPackages( this IPackageRepository repository, string packageId, IVersionSpec versionSpec, bool allowPrereleaseVersions, bool allowUnlisted) { if (repository == null) { throw new ArgumentNullException("repository"); } if (packageId == null) { throw new ArgumentNullException("packageId"); } IEnumerable <IPackage> packages = repository.FindPackagesById(packageId) .OrderByDescending(p => p.Version); if (!allowUnlisted) { packages = packages.Where(PackageExtensions.IsListed); } if (versionSpec != null) { packages = packages.FindByVersion(versionSpec); } packages = DependencyResolveUtility.FilterPackagesByConstraints(NullConstraintProvider.Instance, packages, packageId, allowPrereleaseVersions); return(packages); }
public static IPackage FindPackage(this IPackageRepository repository, string packageId, IVersionSpec versionSpec, IPackageConstraintProvider constraintProvider, bool allowPrereleaseVersions, bool allowUnlisted) { IEnumerable <IPackage> packages = repository.FindPackages(packageId, versionSpec, allowPrereleaseVersions, allowUnlisted); if (constraintProvider != null) { packages = DependencyResolveUtility.FilterPackagesByConstraints(constraintProvider, packages, packageId, allowPrereleaseVersions); } return(packages.FirstOrDefault <IPackage>()); }
public IPackage ResolveDependency(PackageDependency dependency, IPackageConstraintProvider constraintProvider, bool allowPrereleaseVersions, bool preferListedPackages, DependencyVersion dependencyVersion) { if (!this.ResolveDependenciesVertically) { return(DependencyResolveUtility.ResolveDependencyCore(this, dependency, constraintProvider, allowPrereleaseVersions, preferListedPackages, dependencyVersion)); } Func <IPackageRepository, IPackage> resolveDependency = this.Wrap <IPackage>(r => DependencyResolveUtility.ResolveDependency(r, dependency, constraintProvider, allowPrereleaseVersions, preferListedPackages, dependencyVersion), null); return((from r in this.Repositories select Task.Factory.StartNew <IPackage>(() => resolveDependency(r))).ToArray <Task <IPackage> >().WhenAny <IPackage>(package => (package != null))); }
public IPackage ResolveDependency(PackageDependency dependency, IPackageConstraintProvider constraintProvider, bool allowPrereleaseVersions, bool preferListedPackages, DependencyVersion dependencyVersion) { if (ResolveDependenciesVertically) { Func <IPackageRepository, IPackage> resolveDependency = Wrap( r => DependencyResolveUtility.ResolveDependency(r, dependency, constraintProvider, allowPrereleaseVersions, preferListedPackages, dependencyVersion)); return(Repositories.Select(r => Task.Factory.StartNew(() => resolveDependency(r))) .ToArray() .WhenAny(package => package != null)); } return(DependencyResolveUtility.ResolveDependencyCore(this, dependency, constraintProvider, allowPrereleaseVersions, preferListedPackages, dependencyVersion)); }
protected override IPackage ResolveDependency(PackageDependency dependency) { object[] args = new object[] { dependency }; this.Logger.Log(MessageLevel.Info, NuGetResources.Log_AttemptingToRetrievePackageFromSource, args); if (!this._isDowngrade) { IPackage package = DependencyResolveUtility.ResolveDependency(this.Repository, dependency, this.ConstraintProvider, true, false, base.DependencyVersion); if (package != null) { return(package); } } return(this.DependencyResolver.ResolveDependency(dependency, this.ConstraintProvider, this.AllowPrereleaseVersions, true, base.DependencyVersion)); }
public static IPackage FindPackage(this IPackageRepository repository, string packageId, SemanticVersion version, IPackageConstraintProvider constraintProvider, bool allowPrereleaseVersions, bool allowUnlisted) { if (repository == null) { throw new ArgumentNullException("repository"); } if (packageId == null) { throw new ArgumentNullException("packageId"); } if (version != null) { allowUnlisted = true; } else if (!allowUnlisted && ((constraintProvider == null) || ReferenceEquals(constraintProvider, NullConstraintProvider.Instance))) { IPackage package; ILatestPackageLookup lookup2 = repository as ILatestPackageLookup; if ((lookup2 != null) && lookup2.TryFindLatestPackageById(packageId, allowPrereleaseVersions, out package)) { return(package); } } IPackageLookup lookup = repository as IPackageLookup; if ((lookup != null) && (version != null)) { return(lookup.FindPackage(packageId, version)); } IEnumerable <IPackage> packages = from p in repository.FindPackagesById(packageId).ToList <IPackage>() orderby p.Version descending select p; if (!allowUnlisted) { packages = Enumerable.Where <IPackage>(packages, new Func <IPackage, bool>(PackageExtensions.IsListed)); } if (version != null) { packages = from p in packages where p.Version == version select p; } else if (constraintProvider != null) { packages = DependencyResolveUtility.FilterPackagesByConstraints(constraintProvider, packages, packageId, allowPrereleaseVersions); } return(packages.FirstOrDefault <IPackage>()); }
public IPackage ResolveDependency(PackageDependency dependency, IPackageConstraintProvider constraintProvider, bool allowPrereleaseVersions, bool preferListedPackages, DependencyVersion dependencyVersion) { IDependencyResolver dependencyResolver = _repo as IDependencyResolver; if (dependencyResolver != null) { return(dependencyResolver.ResolveDependency(dependency, constraintProvider, allowPrereleaseVersions, preferListedPackages, dependencyVersion)); } return(DependencyResolveUtility.ResolveDependencyCore( _repo, dependency, constraintProvider, allowPrereleaseVersions, preferListedPackages, dependencyVersion)); }
protected override IPackage ResolveDependency(PackageDependency dependency) { Logger.Log(MessageLevel.Info, NuGetResources.Log_AttemptingToRetrievePackageFromSource, dependency); // First try to get a local copy of the package // Bug1638: Include prereleases when resolving locally installed dependencies. //Prerelease is included when we try to look at the local repository. //In case of downgrade, we are going to look only at source repo and not local. //That way we will downgrade dependencies when parent package is downgraded. if (!_isDowngrade) { IPackage package = DependencyResolveUtility.ResolveDependency(Repository, dependency, ConstraintProvider, allowPrereleaseVersions: true, preferListedPackages: false, dependencyVersion: DependencyVersion); if (package != null) { return(package); } } // Next, query the source repo for the same dependency IPackage sourcePackage = DependencyResolver.ResolveDependency(dependency, ConstraintProvider, AllowPrereleaseVersions, preferListedPackages: true, dependencyVersion: DependencyVersion); return(sourcePackage); }
protected override IPackage ResolveDependency(PackageDependency dependency) { return(DependencyResolveUtility.ResolveDependency(_repository, dependency, allowPrereleaseVersions: true, preferListedPackages: false)); }
public void Walk(IPackage package) { CheckPackageMinClientVersion(package); // Do nothing if we saw this package already if (Marker.IsVisited(package)) { ProcessPackageTarget(package); return; } OnBeforePackageWalk(package); // Mark the package as processing Marker.MarkProcessing(package); if (!IgnoreDependencies) { foreach (var dependency in package.GetCompatiblePackageDependencies(TargetFramework)) { // Try to resolve the dependency from the visited packages first IPackage resolvedDependency = DependencyResolveUtility.ResolveDependency( Marker, dependency, constraintProvider: null, allowPrereleaseVersions: AllowPrereleaseVersions, preferListedPackages: false, dependencyVersion: DependencyVersion); if (resolvedDependency == null) { resolvedDependency = ResolveDependency(dependency); } if (resolvedDependency == null) { OnDependencyResolveError(dependency); // If we're skipping dependency resolve errors then move on to the next // dependency if (SkipDependencyResolveError) { continue; } return; } if (!IgnoreWalkInfo) { // Set the parent PackageWalkInfo dependencyInfo = GetPackageInfo(resolvedDependency); dependencyInfo.Parent = package; } Marker.AddDependent(package, resolvedDependency); if (!OnAfterResolveDependency(package, resolvedDependency)) { continue; } if (Marker.IsCycle(resolvedDependency) || Marker.IsVersionCycle(resolvedDependency.Id)) { if (RaiseErrorOnCycle) { List <IPackage> packages = Marker.Packages.ToList(); packages.Add(resolvedDependency); throw new InvalidOperationException( String.Format(CultureInfo.CurrentCulture, NuGetResources.CircularDependencyDetected, String.Join(" => ", packages.Select(p => p.GetFullName())))); } continue; } Walk(resolvedDependency); } } // Mark the package as visited Marker.MarkVisited(package); ProcessPackageTarget(package); OnAfterPackageWalk(package); }
protected override IPackage ResolveDependency(PackageDependency dependency) => DependencyResolveUtility.ResolveDependency(this._repository, dependency, true, false);
public static IPackage FindPackage( this IPackageRepository repository, string packageId, SemanticVersion version, IPackageConstraintProvider constraintProvider, bool allowPrereleaseVersions, bool allowUnlisted) { if (repository == null) { throw new ArgumentNullException("repository"); } if (packageId == null) { throw new ArgumentNullException("packageId"); } // if an explicit version is specified, disregard the 'allowUnlisted' argument // and always allow unlisted packages. if (version != null) { allowUnlisted = true; } else if (!allowUnlisted && (constraintProvider == null || constraintProvider == NullConstraintProvider.Instance)) { var packageLatestLookup = repository as ILatestPackageLookup; if (packageLatestLookup != null) { IPackage package; if (packageLatestLookup.TryFindLatestPackageById(packageId, allowPrereleaseVersions, out package)) { return(package); } } } // If the repository implements it's own lookup then use that instead. // This is an optimization that we use so we don't have to enumerate packages for // sources that don't need to. var packageLookup = repository as IPackageLookup; if (packageLookup != null && version != null) { return(packageLookup.FindPackage(packageId, version)); } IEnumerable <IPackage> packages = repository.FindPackagesById(packageId); packages = packages.ToList() .OrderByDescending(p => p.Version); if (!allowUnlisted) { packages = packages.Where(PackageExtensions.IsListed); } if (version != null) { packages = packages.Where(p => p.Version == version); } else if (constraintProvider != null) { packages = DependencyResolveUtility.FilterPackagesByConstraints(constraintProvider, packages, packageId, allowPrereleaseVersions); } return(packages.FirstOrDefault()); }
public IPackage ResolveDependency(PackageDependency dependency, IPackageConstraintProvider constraintProvider, bool allowPrereleaseVersions, bool preferListedPackages, DependencyVersion dependencyVersion) { IDependencyResolver resolver = this._repo as IDependencyResolver; return((resolver == null) ? DependencyResolveUtility.ResolveDependencyCore(this._repo, dependency, constraintProvider, allowPrereleaseVersions, preferListedPackages, dependencyVersion) : resolver.ResolveDependency(dependency, constraintProvider, allowPrereleaseVersions, preferListedPackages, dependencyVersion)); }