예제 #1
0
        protected override async Task CreateNewAsync(LibraryId id, LibraryIndexJson index, CancellationToken token)
        {
            var package = await GetPackageContentAsync(id, token);

            var specContent = await Api.ExtractSpecAsync(new NuGetPackageId(id.Name, id.Version), package, token);

            await Storage.WriteLibraryFileAsync(id, NuGetConstants.RepositorySpecFileName, specContent, token);

            var spec = Api.ParseSpec(specContent);

            var specLicenseUrl = NuGetConstants.IsDeprecateLicenseUrl(spec.LicenseUrl) ? null : spec.LicenseUrl;

            index.Licenses.Add(await ResolvePackageLicenseAsync(id, spec.License?.Type, spec.License?.Value, specLicenseUrl, token));

            if (!string.IsNullOrEmpty(spec.Repository?.Url))
            {
                index.Licenses.Add(await ResolveUrlLicenseAsync(id, spec.Repository.Url, PackageLicense.SubjectRepository, token));
            }

            if (!spec.ProjectUrl.IsNullOrEmpty())
            {
                index.Licenses.Add(await ResolveUrlLicenseAsync(id, spec.ProjectUrl, PackageLicense.SubjectProject, token));
            }
        }
예제 #2
0
 public void IsDeprecateLicenseUrl(string url, bool expected)
 {
     NuGetConstants.IsDeprecateLicenseUrl(url).ShouldBe(expected);
 }