protected override void OnDependencyResolveError(PackageDependency dependency) { IVersionSpec spec = ConstraintProvider.GetConstraint(dependency.Id); string message = String.Empty; if (spec != null) { message = String.Format(CultureInfo.CurrentCulture, NuGetResources.AdditonalConstraintsDefined, dependency.Id, VersionUtility.PrettyPrint(spec), ConstraintProvider.Source); } throw new InvalidOperationException( String.Format(CultureInfo.CurrentCulture, NuGetResources.UnableToResolveDependency + message, dependency)); }
private void UpdatePackageReference(string packageId, Func <IPackage> resolvePackage, bool updateDependencies, bool allowPrereleaseVersions, bool targetVersionSetExplicitly) { if (String.IsNullOrEmpty(packageId)) { throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "packageId"); } IPackage oldPackage = LocalRepository.FindPackage(packageId); // Check to see if this package is installed if (oldPackage == null) { throw new InvalidOperationException( String.Format(CultureInfo.CurrentCulture, NuGetResources.ProjectDoesNotHaveReference, Project.ProjectName, packageId)); } Logger.Log(MessageLevel.Debug, NuGetResources.Debug_LookingForUpdates, packageId); IPackage package = resolvePackage(); // the condition (allowPrereleaseVersions || targetVersionSetExplicitly || oldPackage.IsReleaseVersion() || !package.IsReleaseVersion() || oldPackage.Version < package.Version) // is to fix bug 1574. We want to do nothing if, let's say, you have package 2.0alpha installed, and you do: // update-package // without specifying a version explicitly, and the feed only has version 1.0 as the latest stable version. if (package != null && oldPackage.Version != package.Version && (allowPrereleaseVersions || targetVersionSetExplicitly || oldPackage.IsReleaseVersion() || !package.IsReleaseVersion() || oldPackage.Version < package.Version)) { Logger.Log(MessageLevel.Info, NuGetResources.Log_UpdatingPackages, package.Id, oldPackage.Version, package.Version, Project.ProjectName); UpdatePackageReference(package, updateDependencies, allowPrereleaseVersions); } else { IVersionSpec constraint = ConstraintProvider.GetConstraint(packageId); if (constraint != null) { Logger.Log(MessageLevel.Info, NuGetResources.Log_ApplyingConstraints, packageId, VersionUtility.PrettyPrint(constraint), ConstraintProvider.Source); } Logger.Log(MessageLevel.Info, NuGetResources.Log_NoUpdatesAvailableForProject, packageId, Project.ProjectName); } }
/// <summary> /// Gets the filename to the specific package <paramref name="packageName"/> using the version <paramref name="versionRange"/> if not null, otherwise the <paramref name="constraintProvider"/> if specified. /// If no constraints are specified, the first entry if any are founds is used to get the filename. /// </summary> /// <param name="packageName">Name of the package.</param> /// <param name="versionRange">The version range.</param> /// <param name="constraintProvider">The package constraint provider.</param> /// <param name="allowPreleaseVersion">if set to <c>true</c> [allow prelease version].</param> /// <param name="allowUnlisted">if set to <c>true</c> [allow unlisted].</param> /// <returns>A location on the disk to the specified package or null if not found.</returns> /// <exception cref="System.ArgumentNullException">packageName</exception> public UFile GetPackageFileName(string packageName, PackageVersionRange versionRange = null, ConstraintProvider constraintProvider = null, bool allowPreleaseVersion = true, bool allowUnlisted = false) { if (packageName == null) { throw new ArgumentNullException(nameof(packageName)); } var package = store.FindLocalPackage(packageName, versionRange, constraintProvider, allowPreleaseVersion, allowUnlisted); // If package was not found, if (package != null) { var packageRoot = (UDirectory)store.GetRealPath(package); var packageFilename = new UFile(packageName + Package.PackageFileExtension); // First look for xkpkg at package root var packageFile = UPath.Combine(packageRoot, packageFilename); if (File.Exists(packageFile)) { return(packageFile); } // Then look for xkpkg inside xenko subfolder packageFile = UPath.Combine(UPath.Combine(packageRoot, (UDirectory)"xenko"), packageFilename); if (File.Exists(packageFile)) { return(packageFile); } } return(null); }
public NugetLocalPackage FindLocalPackage(string packageName, PackageVersionRange versionRange = null, ConstraintProvider constraintProvider = null, bool allowPreleaseVersion = true, bool allowUnlisted = false) { if (packageName == null) { throw new ArgumentNullException(nameof(packageName)); } return(store.FindLocalPackage(packageName, versionRange, constraintProvider, allowPreleaseVersion, allowUnlisted)); }
/// <summary> /// Gets the filename to the specific package <paramref name="packageName"/> using the version <paramref name="versionRange"/> if not null, otherwise the <paramref name="constraintProvider"/> if specified. /// If no constraints are specified, the first entry if any are founds is used to get the filename. /// </summary> /// <param name="packageName">Name of the package.</param> /// <param name="versionRange">The version range.</param> /// <param name="constraintProvider">The package constraint provider.</param> /// <param name="allowPreleaseVersion">if set to <c>true</c> [allow prelease version].</param> /// <param name="allowUnlisted">if set to <c>true</c> [allow unlisted].</param> /// <returns>A location on the disk to the specified package or null if not found.</returns> /// <exception cref="System.ArgumentNullException">packageName</exception> public UFile GetPackageFileName(string packageName, PackageVersionRange versionRange = null, ConstraintProvider constraintProvider = null, bool allowPreleaseVersion = true, bool allowUnlisted = false) { if (packageName == null) { throw new ArgumentNullException(nameof(packageName)); } var package = store.FindLocalPackage(packageName, versionRange, constraintProvider, allowPreleaseVersion, allowUnlisted); // If package was not found, if (package != null) { return(UPath.Combine(store.GetInstallPath(package), new UFile(packageName + Package.PackageFileExtension))); } // TODO: Check version for default package if (packageName == DefaultPackageName) { if (versionRange == null || versionRange.Contains(DefaultPackageVersion)) { return(UPath.Combine(UPath.Combine(UPath.Combine(InstallationPath, (UDirectory)store.RepositoryPath), defaultPackageDirectory), new UFile(packageName + Package.PackageFileExtension))); } } return(null); }