public void UpdatePackage(string packageId, NuGet.SemanticVersion version, bool updateDependencies, bool allowPrereleaseVersions) { if (UpdatePackageWithVersionCallback != null) { UpdatePackageWithVersionCallback(packageId, version, updateDependencies, allowPrereleaseVersions); } }
public void InstallPackage(string packageId, NuGet.SemanticVersion version, bool ignoreDependencies, bool allowPrereleaseVersions) { if (InstallPackageWithVersionCallback != null) { InstallPackageWithVersionCallback(packageId, version, ignoreDependencies, allowPrereleaseVersions); } }
public SearchPackage(ILogger logger, IOctopusServer server, ProjectResource project, SemanticVersion version) { Logger = logger; Server = server; Project = project; Version = version; }
public void UninstallPackage(string packageId, NuGet.SemanticVersion version, bool forceRemove, bool removeDependencies) { if (UninstallPackageWithVersionCallback != null) { UninstallPackageWithVersionCallback(packageId, version, forceRemove, removeDependencies); } }
private void SetupLocalShare(IEnumerable <PackageIdentity> packages) { NuGet.MachineCache.Default.Clear(); foreach (var identity in packages) { string id = identity.Id; NuGet.SemanticVersion version = new NuGet.SemanticVersion(identity.Version.ToNormalizedString()); new PackageManager(PackageRepositoryFactory.Default.CreateRepository(V2SourceUrl), Environment.CurrentDirectory).InstallPackage(id, version); } }
public ReleaseResource GetRelease(ProjectResource project, SemanticVersion semver) { var version = semver.ToNormalizedString(); if (_cache.TryGetValue(CacheKey(CacheKeyType.Release, project.Id, version), out ReleaseResource release)) { return(release); } return(ListReleases(project).SingleOrDefault(package => string.Equals(version, package.Version.ToSemanticVersion().ToNormalizedString(), StringComparison.OrdinalIgnoreCase) || string.Equals(semver.ToOriginalString(), package.Version, StringComparison.OrdinalIgnoreCase))); }
/// <summary> /// Checks if the given package version is present in V2 and V3. This method depends on V2 hijacking to V3. /// </summary> private async Task<bool> CheckIfPackageVersionExistsInV2AndV3Async(string packageId, string version) { var sourceUrl = UrlHelper.V2FeedRootUrl; var repo = PackageRepositoryFactory.Default.CreateRepository(sourceUrl); NuGet.SemanticVersion semVersion = NuGet.SemanticVersion.Parse(version); return await VerifyWithRetryAsync( $"Verifying that package {packageId} {version} exists on source {sourceUrl} (hijacked).", () => { var package = repo.FindPackage(packageId, semVersion); return Task.FromResult(package != null); }); }
public ReleaseResource GetRelease(ProjectResource project, SemanticVersion version) { if (_cache.TryGetValue(CacheKey(CacheKeyType.Release, project.Id, version.ToNormalizedString()), out ReleaseResource release)) { return(release); } TrackCacheEvent(CacheKeyType.Release, project.Id + ";" + version.ToNormalizedString()); return(ListReleases(project).SingleOrDefault(package => { var packageVesion = package.Version.ToSemanticVersion(); return string.Equals(version.ToOriginalString(), packageVesion.ToOriginalString(), StringComparison.OrdinalIgnoreCase) || string.Equals(version.ToNormalizedString(), packageVesion.ToNormalizedString(), StringComparison.OrdinalIgnoreCase) || string.Equals(version.ToFullString(), packageVesion.ToFullString(), StringComparison.OrdinalIgnoreCase); })); }
private static IPackage FindPackage(string packageId, string packageVersion, Uri feed, out PackageDownloader downloader) { var remoteRepository = PackageRepositoryFactory.Default.CreateRepository(feed.AbsoluteUri); downloader = remoteRepository is DataServicePackageRepository dspr ? dspr.PackageDownloader : null; var requiredVersion = new SemanticVersion(packageVersion); var package = remoteRepository.FindPackage(packageId, requiredVersion, true, true); if (package == null) { throw new Exception($"Could not find package {packageId} {packageVersion} in feed: '{feed}'"); } if (!requiredVersion.Equals(package.Version)) { throw new Exception($"The package version '{package.Version}' returned from the package repository doesn't match the requested package version '{requiredVersion}'."); } return(package); }
/// <summary> /// Finds a package from the source repository that matches the id and version. /// </summary> /// <param name="repository">The repository to find the package in.</param> /// <param name="packageId">Id of the package to find.</param> /// <param name="version">Version of the package to find.</param> /// <exception cref="System.InvalidOperationException">If the specified package cannot be found in the repository.</exception> public static IPackage ResolvePackage(IPackageRepository repository, string packageId, SemanticVersion version) { if (repository == null) { throw new ArgumentNullException("repository"); } if (String.IsNullOrEmpty(packageId)) { throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "packageId"); } if (version == null) { throw new ArgumentNullException("version"); } var package = repository.FindPackage(packageId, version); if (package == null) { throw new InvalidOperationException( String.Format(CultureInfo.CurrentCulture, NuGetResources.UnknownPackageSpecificVersion, packageId, version)); } return(package); }
public void InstallPackage(string packageId, SemanticVersion version) { InstallPackage(packageId: packageId, version: version, ignoreDependencies: false, allowPrereleaseVersions: false); }
internal IPackage FindPackage(Func <string, IPackage> openPackage, string packageId, SemanticVersion version) { var lookupPackageName = new PackageName(packageId, version); string packagePath; // If caching is enabled, check if we have a cached path. Additionally, verify that the file actually exists on disk since it might have moved. if (_enableCaching && _packagePathLookup.TryGetValue(lookupPackageName, out packagePath) && FileSystem.FileExists(packagePath)) { // When depending on the cached path, verify the file exists on disk. return(GetPackage(openPackage, packagePath)); } // Lookup files which start with the name "<Id>." and attempt to match it with all possible version string combinations (e.g. 1.2.0, 1.2.0.0) // before opening the package. To avoid creating file name strings, we attempt to specifically match everything after the last path separator // which would be the file name and extension. return((from path in GetPackageLookupPaths(packageId, version) let package = GetPackage(openPackage, path) where lookupPackageName.Equals(new PackageName(package.Id, package.Version)) select package).FirstOrDefault()); }
public virtual bool Exists(string packageId, SemanticVersion version) { return(FindPackage(packageId, version) != null); }
public bool IsReferenced(string packageId, SemanticVersion version) { // See if this package exists in any other repository before we remove it return GetRepositories().Any(r => r.Exists(packageId, version)); }
public virtual void InstallPackage(string packageId, SemanticVersion version, bool ignoreDependencies, bool allowPrereleaseVersions) { IPackage package = PackageRepositoryHelper.ResolvePackage(SourceRepository, LocalRepository, packageId, version, allowPrereleaseVersions); InstallPackage(package, ignoreDependencies, allowPrereleaseVersions); }
public static bool TryParseVersionSpec(string value, out IVersionSpec result) { if (value == null) { throw new ArgumentNullException("value"); } var versionSpec = new VersionSpec(); value = value.Trim(); // First, try to parse it as a plain version string SemanticVersion version; if (SemanticVersion.TryParse(value, out version)) { // A plain version is treated as an inclusive minimum range result = new VersionSpec { MinVersion = version, IsMinInclusive = true }; return(true); } // It's not a plain version, so it must be using the bracket arithmetic range syntax result = null; // Fail early if the string is too short to be valid if (value.Length < 3) { return(false); } // The first character must be [ ot ( switch (value.First()) { case '[': versionSpec.IsMinInclusive = true; break; case '(': versionSpec.IsMinInclusive = false; break; default: return(false); } // The last character must be ] ot ) switch (value.Last()) { case ']': versionSpec.IsMaxInclusive = true; break; case ')': versionSpec.IsMaxInclusive = false; break; default: return(false); } // Get rid of the two brackets value = value.Substring(1, value.Length - 2); // Split by comma, and make sure we don't get more than two pieces string[] parts = value.Split(','); if (parts.Length > 2) { return(false); } else if (parts.All(String.IsNullOrEmpty)) { // If all parts are empty, then neither of upper or lower bounds were specified. Version spec is of the format (,] return(false); } // If there is only one piece, we use it for both min and max string minVersionString = parts[0]; string maxVersionString = (parts.Length == 2) ? parts[1] : parts[0]; // Only parse the min version if it's non-empty if (!String.IsNullOrWhiteSpace(minVersionString)) { if (!TryParseVersion(minVersionString, out version)) { return(false); } versionSpec.MinVersion = version; } // Same deal for max if (!String.IsNullOrWhiteSpace(maxVersionString)) { if (!TryParseVersion(maxVersionString, out version)) { return(false); } versionSpec.MaxVersion = version; } // Successful parse! result = versionSpec; return(true); }
public string GetHashPath(string packageId, SemanticVersion version) { return(Path.Combine(GetInstallPath(packageId, version), $"{packageId}.{version.GetNormalizedVersionString()}{Constants.HashFileExtension}")); }
public string GetManifestFilePath(string packageId, SemanticVersion version) { return(Path.Combine(GetInstallPath(packageId, version), GetManifestFileName(packageId, version))); }
public virtual string GetInstallPath(string packageId, SemanticVersion version) { return(Path.Combine(_fileSystem.Root, GetPackageDirectory(packageId, version))); }
public void UpdatePackage(string packageId, SemanticVersion version, bool updateDependencies, bool allowPrereleaseVersions) { UpdatePackage(packageId, () => SourceRepository.FindPackage(packageId, version, allowPrereleaseVersions, allowUnlisted: false), updateDependencies, allowPrereleaseVersions); }
public void UninstallPackage(string packageId, SemanticVersion version, bool forceRemove) { UninstallPackage(packageId, version: version, forceRemove: forceRemove, removeDependencies: false); }
public virtual string GetManifestFileName(string packageId, SemanticVersion version) { return(packageId + Constants.ManifestExtension); }
public static IPackage ResolvePackage(IPackageRepository sourceRepository, IPackageRepository localRepository, string packageId, SemanticVersion version, bool allowPrereleaseVersions) { return(ResolvePackage(sourceRepository, localRepository, constraintProvider: NullConstraintProvider.Instance, packageId: packageId, version: version, allowPrereleaseVersions: allowPrereleaseVersions)); }
public virtual IPackage LocatePackageToUninstall(IProjectManager projectManager, string id, SemanticVersion version) { var package = LocalRepository.FindPackagesById(id).SingleOrDefault(); if (package == null) { throw new InvalidOperationException(); } return(package); }
private static bool ValidateSpecialVersionLength(SemanticVersion version) { return(version == null || version.SpecialVersion == null || version.SpecialVersion.Length <= 20); }