protected override Task AddNewVersion(string packageId, NuGetPackageVersion nuGetPackageVersion) { if (!this.versions.ContainsKey(packageId)) { this.versions.Add(packageId, new List <NuGetPackageVersion>()); } this.versions[packageId].Add(nuGetPackageVersion); return(Task.CompletedTask); }
public async Task <NuGetPackageViewResponse> ViewPackageInfo(string packageID, string source) { if (string.IsNullOrEmpty(packageID)) { throw new ArgumentNullException("packageID"); } if (string.IsNullOrEmpty(source)) { throw new ArgumentNullException("source"); } NuGetFactory factory = new NuGetFactory(source); var model = new NuGetPackageViewResponse(); model.Request.PackageID = packageID; model.Request.SourceUrl = factory.SourceUrl; model.Request.Source = source; var metaResource = await factory.GetUIMetadata(); var versions = (await CacheGetAllVersionsOfPackage(factory, packageID)).Reverse().Take(10); foreach (var version in versions) { var packageVersion = new NuGetPackageVersion(); #region Meta var versionIdentity = new PackageIdentity(packageID, version); packageVersion = await CacheGetVersionMeta(metaResource, versionIdentity, true); #endregion #region Version Specific packageVersion.IsReleaseVersion = !version.IsPrerelease; packageVersion.IsLegacy = version.IsLegacyVersion; packageVersion.IsPreRelease = version.IsPrerelease; packageVersion.Version = version.ToNormalizedString(); packageVersion.OrderKey = packageVersion.LastUpdatedDate.ToString("yyyyMMdd") + packageVersion.Version; packageVersion.LastUpdated = (packageVersion.LastUpdatedDate == DateTime.MinValue) ? string.Empty : packageVersion.LastUpdatedDate.ToString("MMM dd, yyyy"); #endregion model.Versions.Add(packageVersion); } model.Versions = model.Versions.OrderByDescending(x => x.OrderKey).ToList(); model.LatestVersion = model.Versions.FirstOrDefault(); return(model); }
private static async Task <NuGetPackageVersion> GetVersionMeta(PackageIdentity versionIdentity, UIMetadataResource metaResource, bool getDependencies) { var packageVersion = new NuGetPackageVersion(); var meta = await metaResource.GetMetadata(versionIdentity, CancellationToken.None); packageVersion.PackageID = meta.Identity.Id; packageVersion.Description = meta.Description; //Uri packageVersion.IconUri = meta.IconUrl; packageVersion.ProjectUri = meta.ProjectUrl == null ? "#" : meta.ProjectUrl.AbsoluteUri; packageVersion.LicenseUri = meta.LicenseUrl == null ? "#" : meta.LicenseUrl.AbsoluteUri; packageVersion.ReportAbuseUri = meta.ReportAbuseUrl.AbsoluteUri; //TODO:Currently NuGet API return blank packageVersion.Authors = String.Join(",", meta.Authors); packageVersion.Owners = String.Join(",", meta.Owners); //Supported Frameworks packageVersion.SupportedFrameworks = new List <NuGetFrameworkInfo>(); if (getDependencies) { foreach (var item in meta.DependencySets) { if (item.TargetFramework.IsUnsupported) { continue; } NuGetFrameworkInfo fxInfo = NuGetFrameworkInfo.CreateFrom(item.TargetFramework); var dependentOn = item.Packages.Count(); if (dependentOn > 0) { fxInfo.DependencyCount = dependentOn; } packageVersion.SupportedFrameworks.Add(fxInfo); } if (!packageVersion.SupportedFrameworks.Any()) { packageVersion.SupportedFrameworks.Add(NuGetFrameworkInfo.Any()); } } return(packageVersion); }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { await Task.Yield(); ApplicationSettings applicationSettings = await _applicationSettingsStore.GetApplicationSettings(stoppingToken); if (!applicationSettings.HostAgentEnabled) { _logger.Information("Host agent is disabled"); return; } string?exePath = applicationSettings.AgentExe; if (string.IsNullOrWhiteSpace(applicationSettings.AgentExe)) { _logger.Debug("No agent exe has been specified"); var currentVersion = await GetCurrentVersionAsync(); NuGetPackageVersion nuGetPackageVersion = currentVersion is {}
protected override Task AddNewVersion(string pacakgeId, NuGetPackageVersion nuGetPackageVersion) { throw new NotImplementedException(); }
/// <summary> /// Add a new version of a package /// </summary> /// <param name="packageId"></param> /// <param name="nuGetPackageVersion"></param> /// <returns></returns> protected abstract Task AddNewVersion(string packageId, NuGetPackageVersion nuGetPackageVersion);