Table of Contents

Interface INugetPackageUnlistHelper

Namespace
Invex.RepoUtils.Atom.Module.Helpers
Assembly
Invex.RepoUtils.Atom.Module.dll

Provides functionality for discovering and unlisting prerelease packages that have been superseded by a newly published version. Versions are discovered through the NuGet flat-container API and unlisted via the feed's HTTP DELETE endpoint, with a summary written to the Atom build report.

public interface INugetPackageUnlistHelper : IReportsHelper, IBuildAccessor
Inherited Members
IReportsHelper.AddReportData(IReportData)
IBuildAccessor.GetService<T>()
IBuildAccessor.GetServices<T>()
IBuildAccessor.GetParam<T>(Expression<Func<T>>, T, Func<string, T>)
IBuildAccessor.Services
IBuildAccessor.Logger
IBuildAccessor.RootedFileSystem
IBuildAccessor.ProcessRunner

Fields

FlatContainerResourceType

The NuGet flat-container resource type advertised in a feed's service index.

public const string FlatContainerResourceType = "PackageBaseAddress/3.0.0"

Field Value

string

MaxHttpAttempts

The maximum number of attempts (including the initial attempt) made for each HTTP request before giving up.

public const int MaxHttpAttempts = 3

Field Value

int

PublishResourceType

The NuGet package publish resource type advertised in a feed's service index. The same base address is used to unlist packages via an HTTP DELETE.

public const string PublishResourceType = "PackagePublish/2.0.0"

Field Value

string

Methods

SelectPrereleasesBelowVersion(SemVer, IEnumerable<SemVer>)

Selects every published prerelease version whose SemVer precedence is strictly below version. Stable versions and prereleases at or above the given version are never selected, which makes this suitable for cleaning up obsolete prerelease packages left behind once a newer stable version has shipped.

public static IReadOnlyList<SemVer> SelectPrereleasesBelowVersion(SemVer version, IEnumerable<SemVer> publishedVersions)

Parameters

version SemVer

The exclusive version ceiling (typically a stable version); only prereleases with lower precedence are selected.

publishedVersions IEnumerable<SemVer>

All versions currently published for the package.

Returns

IReadOnlyList<SemVer>

The matching prerelease versions in ascending precedence order. For example, a version of 2.0.0 selects every prerelease below 2.0.0 (such as 1.5.0-rc.1 and 2.0.0-rc.1) while leaving every stable version and every prerelease at or above 2.0.0 untouched.

SelectSupersededPrereleases(SemVer, IEnumerable<SemVer>)

Selects the published versions that are superseded by currentVersion: every version that shares the same Invex.SemanticVersion.SemVer.Prefix (core MAJOR.MINOR.PATCH), is a prerelease, and has lower SemVer precedence than the current version.

public static IReadOnlyList<SemVer> SelectSupersededPrereleases(SemVer currentVersion, IEnumerable<SemVer> publishedVersions)

Parameters

currentVersion SemVer

The version that was just published.

publishedVersions IEnumerable<SemVer>

All versions currently published for the package.

Returns

IReadOnlyList<SemVer>

The superseded prerelease versions in ascending precedence order. A stable currentVersion matches all prereleases of the same core version, while a versions of a different core, equal/higher versions, and the current version itself are never selected.

UnlistPrereleasesBelowVersionForPackages(string, string, IEnumerable<string>, SemVer, CancellationToken)

Unlists every prerelease package version whose SemVer precedence is strictly below version for the supplied package ids, and writes a summary of the work performed to the Atom build report. This is intended for a manually-triggered cleanup of old prerelease packages left behind once a newer stable version has shipped.

Task<IReadOnlyList<UnlistResult>> UnlistPrereleasesBelowVersionForPackages(string feedUrl, string apiKey, IEnumerable<string> packageIds, SemVer version, CancellationToken cancellationToken)

Parameters

feedUrl string

The service index URL of the NuGet feed (for example, https://api.nuget.org/v3/index.json ).

apiKey string

The API key used to authenticate the unlist (DELETE) requests.

packageIds IEnumerable<string>

The ids of the packages whose old prereleases should be unlisted.

version SemVer

The exclusive version ceiling (typically a stable version); only prereleases with lower precedence are unlisted.

cancellationToken CancellationToken

A token used to cancel the operation.

Returns

Task<IReadOnlyList<UnlistResult>>

The per-version results of the unlist attempts.

Exceptions

StepFailedException

Thrown when one or more versions could not be unlisted after retries.

UnlistSupersededPrereleasesForPackages(string, string, IEnumerable<string>, SemVer, CancellationToken)

Unlists every prerelease package version that is superseded by currentVersion for the supplied package ids, and writes a summary of the work performed to the Atom build report.

Task<IReadOnlyList<UnlistResult>> UnlistSupersededPrereleasesForPackages(string feedUrl, string apiKey, IEnumerable<string> packageIds, SemVer currentVersion, CancellationToken cancellationToken)

Parameters

feedUrl string

The service index URL of the NuGet feed (for example, https://api.nuget.org/v3/index.json ).

apiKey string

The API key used to authenticate the unlist (DELETE) requests.

packageIds IEnumerable<string>

The ids of the packages whose superseded prereleases should be unlisted.

currentVersion SemVer

The version that was just published, used as the supersedence baseline.

cancellationToken CancellationToken

A token used to cancel the operation.

Returns

Task<IReadOnlyList<UnlistResult>>

The per-version results of the unlist attempts.

Exceptions

StepFailedException

Thrown when one or more versions could not be unlisted after retries.