async Task <IPackageSearchMetadata> GetPackageMetadataAsync(PackageIdentity identity, bool includePrerelease, CancellationToken cancellationToken) { // first we try and load the metadata from a local package var packageMetadata = await _metadataProvider.GetLocalPackageMetadataAsync(identity, includePrerelease, cancellationToken); if (packageMetadata == null) { // and failing that we go to the network packageMetadata = await _metadataProvider.GetPackageMetadataAsync(identity, includePrerelease, cancellationToken); } return(packageMetadata); }
internal virtual async Task <IPackageSearchMetadata> GetPackageMetadataAsync <T>(T identity, bool includePrerelease, CancellationToken cancellationToken) where T : PackageIdentity { cancellationToken.ThrowIfCancellationRequested(); // first we try and load the metadata from a local package var packageMetadata = await _metadataProvider.GetLocalPackageMetadataAsync(identity, includePrerelease, cancellationToken); if (packageMetadata == null) { // and failing that we go to the network packageMetadata = await _metadataProvider.GetPackageMetadataAsync(identity, includePrerelease, cancellationToken); } return(packageMetadata); }
/// <summary> /// Get installed local metadata based on package.config /// </summary> /// <param name="token"></param> /// <param name="cancellationToken"></param> /// <returns></returns> private async Task <DeferToken> GetMetadataFromLocalSourcesAsync(DeferToken token, CancellationToken cancellationToken) { var project = _projectProvider.GetDefaultProject(); string packageId = token.Package.Identity.Id; if (project is null) { return(token); } var installedVersion = await _projectManager.GetVersionInstalledAsync(project, packageId, cancellationToken); if (installedVersion is null) { return(token); } var metadata = await _packageMetadataProvider.GetLocalPackageMetadataAsync(new PackageIdentity(packageId, installedVersion), true, cancellationToken); token.Result = metadata; return(token); }
public async Task <bool> PackageExistsAsync(IRepository packageRepository, IPackageDetails packageDetails) { var versionsMetadata = await _packageMetadataProvider.GetLocalPackageMetadataAsync(new PackageIdentity(packageDetails.Id, packageDetails.NuGetVersion), true, CancellationToken.None); return(versionsMetadata is not null); }