Exemple #1
0
		private PackageInfo QueryPackageInfo(PackageName packageRef, bool findMaxVersionBelow)
		{
			NuGet.IPackage package = this.FindPackageInfo(packageRef, findMaxVersionBelow);
			return package != null ? this.CreatePackageInfo(package) : null;
		}
Exemple #2
0
		private NuGet.IPackage FindPackageInfo(PackageName packageRef, bool findMaxVersionBelow)
		{
			// Find a direct version match
			if (packageRef.Version != null && !findMaxVersionBelow)
			{
				// Query locally first, since we're looking for a specific version number anyway.
				foreach (NuGet.IPackage package in this.manager.LocalRepository.FindPackagesById(packageRef.Id))
				{
					if (package.Version.Version == packageRef.Version)
						return package;
				}

				// Nothing found? Query online then.
				try
				{
					foreach (NuGet.IPackage package in this.GetRepositoryPackages(packageRef.Id))
					{
						if (package.Version.Version == packageRef.Version)
							return package;
					}
				}
				catch (Exception)
				{
					return null;
				}
			}
			// Find the newest available version online
			else
			{
				NuGet.IPackage[] data = null;
				try
				{
					IEnumerable<NuGet.IPackage> query = this.GetRepositoryPackages(packageRef.Id);
					data = query.ToArray();
				}
				catch (Exception)
				{
					return null;
				}

				var packageQuery = data.Where(p => p.IsListed() && p.IsReleaseVersion());
				if (findMaxVersionBelow && packageRef.Version != null)
					packageQuery = packageQuery.Where(p => p.Version.Version < packageRef.Version);

				NuGet.IPackage newestPackage = packageQuery
					.OrderByDescending(p => p.Version.Version)
					.FirstOrDefault();

				if (newestPackage != null)
					return newestPackage;
			}

			// Nothing was found
			return null;
		}
		public PackageLicenseAgreementEventArgs(PackageName package, Uri licenseUrl, bool requireAccept) : base(package)
		{
			this.licenseUrl = licenseUrl;
			this.requireLicenseAcceptance = requireAccept;
		}
Exemple #4
0
		public PackageInfo QueryPackageInfo(PackageName packageRef)
		{
			return this.QueryPackageInfo(packageRef, false);
		}
Exemple #5
0
		internal PackageInfo(PackageName package)
		{
			this.packageName = package;
		}
		public PackageEventArgs(PackageName package)
		{
			this.packageName = package;
		}
Exemple #7
0
 internal PackageInfo(PackageName package)
 {
     this.packageName = package;
 }
Exemple #8
0
 /// <summary>
 /// Uninstalls the specified package.
 /// </summary>
 /// <param name="packageName"></param>
 public void UninstallPackage(PackageName packageName)
 {
     this.UninstallPackage(packageName, false);
 }
Exemple #9
0
 private PackageInfo QueryPackageInfo(PackageName packageRef, bool findMaxVersionBelow)
 {
     NuGet.IPackage package = this.FindPackageInfo(packageRef, findMaxVersionBelow);
     return(package != null?this.CreatePackageInfo(package) : null);
 }
Exemple #10
0
        private NuGet.IPackage FindPackageInfo(PackageName packageRef, bool findMaxVersionBelow)
        {
            // Find a direct version match
            if (packageRef.Version != null && !findMaxVersionBelow)
            {
                // Query locally first, since we're looking for a specific version number anyway.
                foreach (NuGet.IPackage package in this.manager.LocalRepository.FindPackagesById(packageRef.Id))
                {
                    if (package.Version.Version == packageRef.Version)
                    {
                        return(package);
                    }
                }

                // Nothing found? Query online then.
                try
                {
                    foreach (NuGet.IPackage package in this.GetRepositoryPackages(packageRef.Id))
                    {
                        if (package.Version.Version == packageRef.Version)
                        {
                            return(package);
                        }
                    }
                }
                catch (Exception)
                {
                    return(null);
                }
            }
            // Find the newest available version online
            else
            {
                NuGet.IPackage[] data = null;
                try
                {
                    IEnumerable <NuGet.IPackage> query = this.GetRepositoryPackages(packageRef.Id);
                    data = query.ToArray();
                }
                catch (Exception)
                {
                    return(null);
                }

                var packageQuery = data.Where(p => p.IsListed() && p.IsReleaseVersion());
                if (findMaxVersionBelow && packageRef.Version != null)
                {
                    packageQuery = packageQuery.Where(p => p.Version.Version < packageRef.Version);
                }

                NuGet.IPackage newestPackage = packageQuery
                                               .OrderByDescending(p => p.Version.Version)
                                               .FirstOrDefault();

                if (newestPackage != null)
                {
                    return(newestPackage);
                }
            }

            // Nothing was found
            return(null);
        }
Exemple #11
0
 public PackageInfo QueryPackageInfo(PackageName packageRef)
 {
     return(this.QueryPackageInfo(packageRef, false));
 }
Exemple #12
0
 /// <summary>
 /// Retrieves detailed information about the specified package from the
 /// local or remote repository.
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public PackageInfo GetPackage(PackageName name)
 {
     return(this.cache.GetPackage(name));
 }
Exemple #13
0
        private void UninstallPackage(PackageName packageName, bool force)
        {
            Log.Editor.Write("Uninstalling package '{0}'...", packageName);
            Log.Editor.PushIndent();
            try
            {
                // Find the local package that we'll uninstall
                NuGet.IPackage uninstallPackage = this.manager.LocalRepository
                                                  .FindPackagesById(packageName.Id)
                                                  .FirstOrDefault(p => p.Version.Version == packageName.Version);
                if (uninstallPackage == null)
                {
                    return;
                }

                // Find all dependencies of the package we want to uninstall
                PackageName        uninstallPackageName  = new PackageName(uninstallPackage.Id, uninstallPackage.Version.Version);
                PackageInfo        uninstallPackageInfo  = this.GetPackage(uninstallPackageName);
                List <PackageInfo> uninstallDependencies = new List <PackageInfo>();
                if (uninstallPackageInfo != null)
                {
                    this.dependencyWalker.Clear();
                    this.dependencyWalker.WalkGraph(uninstallPackageInfo);
                    uninstallDependencies.AddRange(this.dependencyWalker.VisitedPackages);
                    uninstallDependencies.RemoveAll(package => package.Id == uninstallPackageInfo.Id);
                }

                // Filter out all dependencies that are used by other Duality packages
                foreach (LocalPackage otherPackage in this.LocalSetup.Packages)
                {
                    if (otherPackage.Id == uninstallPackage.Id)
                    {
                        continue;
                    }

                    PackageInfo otherPackageInfo = otherPackage.Info ?? this.GetPackage(otherPackage.Name);
                    if (otherPackageInfo == null)
                    {
                        continue;
                    }

                    this.dependencyWalker.Clear();
                    this.dependencyWalker.IgnorePackage(uninstallPackage.Id);
                    this.dependencyWalker.WalkGraph(otherPackageInfo);
                    foreach (PackageInfo dependency in this.dependencyWalker.VisitedPackages)
                    {
                        // Don't check versions, as dependencies are usually not resolved
                        // with an exact version match.
                        uninstallDependencies.RemoveAll(item => item.Id == dependency.Id);
                    }
                }

                // Uninstall the package itself
                this.manager.UninstallPackage(
                    uninstallPackage,
                    force);

                // Uninstall its dependencies that are no longer used, in reverse dependency order
                // to avoid stumbling over dependencies that they might have between each other.
                this.OrderByDependencies(uninstallDependencies);
                uninstallDependencies.Reverse();
                foreach (PackageInfo package in uninstallDependencies)
                {
                    List <NuGet.IPackage> matchingNuGetPackages = this.manager.LocalRepository
                                                                  .FindPackagesById(package.Id)
                                                                  .ToList();

                    foreach (NuGet.IPackage nugetPackage in matchingNuGetPackages)
                    {
                        this.manager.UninstallPackage(nugetPackage, force, false);
                    }
                }
            }
            finally
            {
                Log.Editor.PopIndent();
            }
        }
Exemple #14
0
		internal LocalPackage(PackageInfo info)
		{
			this.packageName = info.PackageName;
			this.info = info;
		}
Exemple #15
0
		public PackageInfo QueryPackageInfo(PackageName packageRef)
		{
			NuGet.IPackage package = this.FindPackageInfo(packageRef);
			return package != null ? this.CreatePackageInfo(package) : null;
		}
Exemple #16
0
		internal LocalPackage(PackageName package)
		{
			this.packageName = package;
			this.info = null;
		}
Exemple #17
0
 /// <summary>
 /// Installs the specified package.
 /// </summary>
 /// <param name="packageName"></param>
 public void InstallPackage(PackageName packageName)
 {
     this.InstallPackage(packageName, false);
 }