Exemple #1
0
        /// <summary>
        /// Verifies that a package has been previously installed as well as
        /// currently existing locally with all dependencies, and if so,
        /// adds it back to the outgoing cache file along with all it's
        /// previously calculated dependencies.
        /// </summary>
        public bool VerifyPackage(PackageIdentity packageIdentity, NuGetPackageManager packageManager)
        {
            CachedPackage cached = _cachedPackages.FirstOrDefault(x =>
                                                                  x.PackageReference.PackageIdentity.Id.Equals(packageIdentity.Id, StringComparison.OrdinalIgnoreCase) &&
                                                                  x.PackageReference.PackageIdentity.Version.Equals(packageIdentity.Version));

            if (cached != null && cached.VerifyPackage(packageManager))
            {
                _installedPackages.Add(cached);
                return(true);
            }
            return(false);
        }
Exemple #2
0
        public IDisposable AddPackage(PackageIdentity identity, NuGetFramework targetFramework)
        {
            if (_currentlyInstallingPackage != null && _currentlyInstallingPackage.CurrentlyInstalling)
            {
                // We're currently installing a package, so add the dependency to that one
                // Make sure this isn't the actual top-level package
                if (!_currentlyInstallingPackage.CachedPackage.PackageReference.PackageIdentity.Equals(identity) ||
                    !_currentlyInstallingPackage.CachedPackage.PackageReference.TargetFramework.Equals(targetFramework))
                {
                    _currentlyInstallingPackage.CachedPackage.AddDependency(new CachedPackage(identity, targetFramework));
                }
                return(EmptyDisposable.Instance);
            }

            // This is a new top-level installation, so add to the root
            CachedPackage cachedPackage = new CachedPackage(identity, targetFramework);

            _installedPackages.Add(cachedPackage);
            _currentlyInstallingPackage = new CachedPackageEntry(cachedPackage);
            return(_currentlyInstallingPackage);
        }
Exemple #3
0
 public CachedPackageEntry(CachedPackage cachedPackage)
 {
     CachedPackage       = cachedPackage;
     CurrentlyInstalling = true;
 }
 public void AddDependency(CachedPackage cachedPackage)
 {
     Element.Add(cachedPackage.Element);
     _dependencies.Add(cachedPackage);
 }