Beispiel #1
0
        public override void Write(PackageVersionEntry packageVersionEntry, IEnumerable <string> netFrameworkPackageVersions, IEnumerable <string> netCorePackageVersions)
        {
            Debug.Assert(Started, "Cannot call Write() before calling Start()");
            Debug.Assert(!Finished, "Cannot call Write() after calling Finish()");

            var bodyStringBuilder = new StringBuilder();

            bodyStringBuilder.Append(IfNetFrameworkDirectiveConst);
            foreach (var packageVersion in netFrameworkPackageVersions)
            {
                bodyStringBuilder.AppendLine();
                bodyStringBuilder.Append(string.Format(EntryFormat, packageVersion));
            }

            bodyStringBuilder.Append(EndIfDirectiveConst);

            foreach (var packageVersion in netCorePackageVersions)
            {
                bodyStringBuilder.AppendLine();
                bodyStringBuilder.Append(string.Format(EntryFormat, packageVersion));
            }

            string ifDirective    = string.IsNullOrEmpty(packageVersionEntry.SampleTargetFramework) ? string.Empty : $"#if {packageVersionEntry.SampleTargetFramework.ToUpper().Replace('.', '_')}{Environment.NewLine}";
            string endifDirective = string.IsNullOrEmpty(packageVersionEntry.SampleTargetFramework) ? string.Empty : EndIfDirectiveConst;

            FileStringBuilder.AppendLine(string.Format(BodyFormat, ifDirective, packageVersionEntry.IntegrationName, bodyStringBuilder.ToString(), endifDirective));
        }
        public override void Write(PackageVersionEntry packageVersionEntry, IEnumerable <string> packageVersions)
        {
            Debug.Assert(Started, "Cannot call Write() before calling Start()");
            Debug.Assert(!Finished, "Cannot call Write() after calling Finish()");

            StringBuilder bodyStringBuilder = new StringBuilder();

            foreach (string packageVersion in packageVersions)
            {
                string targetFrameworkProperty = string.IsNullOrEmpty(packageVersionEntry.SampleTargetFramework) ? string.Empty : string.Format(TargetFrameworkFormat, packageVersionEntry.SampleTargetFramework);
                FileStringBuilder.AppendLine(string.Format(EntryFormat, packageVersionEntry.SampleProjectName, packageVersion, targetFrameworkProperty));
            }
        }
Beispiel #3
0
        public static async Task <IEnumerable <string> > GetNugetPackageVersions(PackageVersionEntry entry)
        {
            var packageSource = new PackageSource("https://api.nuget.org/v3/index.json");

            var providers = new List <Lazy <INuGetResourceProvider> >();

            providers.AddRange(Repository.Provider.GetCoreV3()); // Add v3 API support
            // providers.AddRange(Repository.Provider.GetCoreV2()); // Add v2 API support

            var sourceRepository        = new SourceRepository(packageSource, providers);
            var packageMetadataResource = await sourceRepository.GetResourceAsync <PackageMetadataResource>();

            var downloadResource = await sourceRepository.GetResourceAsync <DownloadResource>();

            var sourceCacheContext = new SourceCacheContext();
            var logger             = new Logger();

            var searchMetadata = await packageMetadataResource.GetMetadataAsync(
                entry.NugetPackageSearchName,
                includePrerelease : false,
                includeUnlisted : true,
                sourceCacheContext,
                logger,
                CancellationToken.None);

            SemanticVersion minSemanticVersion, maxSemanticVersionExclusive;

            if (!SemanticVersion.TryParse(entry.MinVersion, out minSemanticVersion))
            {
                throw new ArgumentException($"MinVersion {entry.MinVersion} in integration {entry.IntegrationName} could not be parsed into a NuGet Semantic Version");
            }

            if (!SemanticVersion.TryParse(entry.MaxVersionExclusive, out maxSemanticVersionExclusive))
            {
                throw new ArgumentException($"MaxVersion {entry.MaxVersionExclusive} in integration {entry.IntegrationName} could not be parsed into a NuGet Semantic Version");
            }

            List <string> packageVersions = new List <string>();

            foreach (var md in searchMetadata)
            {
                if (md.Identity.HasVersion && md.Identity.Version.CompareTo(minSemanticVersion) >= 0 && md.Identity.Version.CompareTo(maxSemanticVersionExclusive) < 0)
                {
                    packageVersions.Add(md.Identity.Version.ToNormalizedString());
                }
            }

            return(packageVersions);
        }
Beispiel #4
0
 public void Write(PackageVersionEntry entry, HashSet <string> versions)
 {
     _msBuildPropsFileGenerator.Write(entry, versions);
     _xUnitFileGenerator.Write(entry, versions);
 }
Beispiel #5
0
 public abstract void Write(PackageVersionEntry packageVersionEntry, IEnumerable <string> netFrameworkPackageVersions, IEnumerable <string> netCorePackageVersions);
Beispiel #6
0
 public override void Write(PackageVersionEntry packageVersionEntry, IEnumerable <(TargetFramework framework, IEnumerable <Version> versions)> versions)
Beispiel #7
0
 public override void Write(PackageVersionEntry packageVersionEntry, IEnumerable <(TargetFramework framework, IEnumerable <Version> versions)> versions, bool requiresDockerDependency)
Beispiel #8
0
 public void Write(PackageVersionEntry entry, IEnumerable <string> netFrameworkversions, IEnumerable <string> netCoreVersions)
 {
     _msBuildPropsFileGenerator.Write(entry, netFrameworkversions, netCoreVersions);
     _xUnitFileGenerator.Write(entry, netFrameworkversions, netCoreVersions);
 }
 public abstract void Write(PackageVersionEntry packageVersionEntry, IEnumerable <(TargetFramework framework, IEnumerable <Version> versions)> versions);
Beispiel #10
0
 public abstract void Write(PackageVersionEntry packageVersionEntry, IEnumerable <string> packageVersions);