Docs · API reference · Verso.Extensions.Marketplace

NuGetMarketplaceService Class#

Searches NuGet for extension packages and installs them into the managed extensions directory. Search uses the NuGet v3 NuGet.Protocol.Core.Types.PackageSearchResource; install delegates downloading and transitive resolution to Verso.Kernels.NuGetPackageResolver and then copies the resolved assemblies into a stable per-package directory so they persist across sessions and can be reloaded offline. Because the managed directory is shared by every Verso host on the machine and hosts can run on different .NET runtime majors (the notebook host rolls forward to the newest installed runtime), each install is partitioned into a per-runtime subfolder so one host's assets never poison another's.

public sealed class NuGetMarketplaceService

Inheritance System.Object → NuGetMarketplaceService

Properties#

SourceNames Property#

The configured package sources, in the order they are searched. Surfaced so the extension panel can say where its results came from rather than assuming nuget.org, which is wrong for anyone with a private feed in their NuGet configuration.

public System.Collections.Generic.IReadOnlyList<string> SourceNames { get; }

Property Value#

System.Collections.Generic.IReadOnlyList<System.String>

Methods#

EnsureInstalledAsync(string, string, string, CancellationToken) Method#

Ensures a package is present in the managed extensions directory and returns the assembly paths to load. When a copy this runtime can load is already installed this is offline and fast; otherwise the package and its transitive dependencies are downloaded, then copied into {managedDir}/{id}/{version}/{netN.0}/, where the last segment records the minimum runtime the assets require (see Verso.Extensions.Marketplace.NuGetMarketplaceService.TryPickCompatibleAssemblies(System.String)). The package directory is registered with the runtime resolver so co-located dependency assemblies resolve when the extension is loaded.

public System.Threading.Tasks.Task<Verso.Extensions.Marketplace.MarketplaceInstallResult> EnsureInstalledAsync(string packageId, string? version, string managedDir, System.Threading.CancellationToken ct);

Parameters#

packageId System.String

version System.String

managedDir System.String

ct System.Threading.CancellationToken

Returns#

System.Threading.Tasks.Task<MarketplaceInstallResult>

GetAvailableVersionsAsync(string, bool, CancellationToken) Method#

Lists the versions available to install for packageId, newest first. Drives the marketplace's version picker so a user can install a version other than the latest. The first source that can enumerate the id wins; sources without an all-versions endpoint, or that don't carry the package, are skipped. Returns an empty list when no source can resolve the id. Pre-release versions are excluded unless includePrerelease is set.

public System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<string>> GetAvailableVersionsAsync(string packageId, bool includePrerelease, System.Threading.CancellationToken ct);

Parameters#

packageId System.String

includePrerelease System.Boolean

ct System.Threading.CancellationToken

Returns#

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<System.String>>

InstallFromFileAsync(string, string, CancellationToken) Method#

Installs a sideloaded local extension file into the managed directory. A loose .dll is copied into {managedDir}/{assemblyName}/{assemblyVersion}/{netN.0}/; a .nupkg is resolved like any other NuGet package (its containing folder is added as a source so the package itself is found locally while transitive dependencies still resolve from configured feeds) and the resulting closure is copied into {managedDir}/{id}/{version}/{netN.0}/. The trailing segment records the minimum runtime the assemblies require (see Verso.Extensions.Marketplace.NuGetMarketplaceService.TryPickCompatibleAssemblies(System.String)). The package directory is registered with the runtime resolver so co-located dependencies resolve when the extension loads.

public System.Threading.Tasks.Task<Verso.Extensions.Marketplace.LocalInstallResult> InstallFromFileAsync(string localFilePath, string managedDir, System.Threading.CancellationToken ct);

Parameters#

localFilePath System.String

managedDir System.String

ct System.Threading.CancellationToken

Returns#

System.Threading.Tasks.Task<LocalInstallResult>

PeekLocalIdentity(string) Method#

Reads the package id and version a local file would install as, without loading any code: a .nupkg reports its package identity; a .dll reports its assembly name and version. Returns null for a missing or unsupported file. Used to drive the consent prompt before the assembly is loaded.

public static System.Nullable<(string Id,string? Version)> PeekLocalIdentity(string localFilePath);

Parameters#

localFilePath System.String

Returns#

System.Nullable<<System.String,System.String>>

ResolveVersionAsync(string, string, CancellationToken) Method#

Resolves the concrete version a reference would install as, without downloading. A pinned reference returns its own version; an unpinned ("latest") reference is resolved against the configured sources. Returns null when a latest reference cannot be resolved (offline or package not found), so the caller can fall back or report it.

public System.Threading.Tasks.Task<string?> ResolveVersionAsync(string packageId, string? version, System.Threading.CancellationToken ct);

Parameters#

packageId System.String

version System.String

ct System.Threading.CancellationToken

Returns#

System.Threading.Tasks.Task<System.String>

SearchAsync(string, int, int, bool, CancellationToken) Method#

Searches the configured sources for packages matching query. The first source that exposes a search resource is used (local-directory feeds do not support search; the nuget.org fallback always does).

public System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Verso.Extensions.Marketplace.MarketplaceSearchItem>> SearchAsync(string query, int skip, int take, bool includePrerelease, System.Threading.CancellationToken ct);

Parameters#

query System.String

skip System.Int32

take System.Int32

includePrerelease System.Boolean

ct System.Threading.CancellationToken

Returns#

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<MarketplaceSearchItem>>

TryReadPackageIconDataUri(string, string, string) Method#

Reads the installed icon for a package as a data: URI, or returns null when the package has no icon, was installed before icons were kept, or is a loose assembly with no package to carry one. Reading locally rather than fetching the feed's icon URL means the pane makes no network request, works offline, and shows the icon for sideloaded packages that no feed knows about.

public static string? TryReadPackageIconDataUri(string packageId, string? version, string managedDir);

Parameters#

packageId System.String

The package to read the icon for.

version System.String

The pinned version, or null for an unpinned reference, in which case the highest installed version supplies the icon.

managedDir System.String

The managed extension directory holding installed packages.

Returns#

System.String

TryResolveInstalled(string, string, string) Method#

Returns the assembly paths for a package already laid down in the managed directory, without contacting any feed. Used to reload sideloaded local extensions on open: a local file cannot be re-fetched, so a missing managed directory yields null rather than a download attempt. Returns null when the version is unknown or no assemblies this runtime can load are present.

public Verso.Extensions.Marketplace.MarketplaceInstallResult? TryResolveInstalled(string packageId, string? version, string managedDir);

Parameters#

packageId System.String

version System.String

managedDir System.String

Returns#

MarketplaceInstallResult

TryResolveInstalledLatest(string, string) Method#

Returns the highest version of a package already laid down in the managed directory, without contacting any feed. Used as an offline fallback for an unpinned ("latest") required extension when the feed cannot be reached: a previously downloaded copy still loads. Returns null when nothing this runtime can load is installed for the package.

public Verso.Extensions.Marketplace.MarketplaceInstallResult? TryResolveInstalledLatest(string packageId, string managedDir);

Parameters#

packageId System.String

managedDir System.String

Returns#

MarketplaceInstallResult