Ejemplo n.º 1
0
        private async Task RunFileGeneratorWithPackageEntries(IEnumerable <PackageVersionEntry> entries, Solution solution)
        {
            _latestMinors.Start();
            _latestMajors.Start();
            _latestSpecific.Start();
            _strategyGenerator.Start();

            foreach (var entry in entries)
            {
                var project = solution.GetProject(entry.SampleProjectName);
                var supportedTargetFrameworks = project
                                                .GetTargetFrameworks()
                                                .Select(x => (TargetFramework) new TargetFramework.TargetFrameworkTypeConverter().ConvertFrom(x));

                var requiresDockerDependency = project.RequiresDockerDependency();

                var packageVersions = await NuGetPackageHelper.GetNugetPackageVersions(entry);

                var orderedPackageVersions =
                    packageVersions
                    .Distinct()
                    .Select(versionText => new Version(versionText))
                    .OrderBy(v => v)
                    .ToList();

                var orderedWithFramework = (
                    from version in orderedPackageVersions
                    from framework in supportedTargetFrameworks
                    where IsSupported(entry, version.ToString(), framework)
                    select(version, framework))
                                           .ToList();

                // Add the last for every minor
                var latestMajors   = SelectMax(orderedWithFramework, v => v.Major).ToList();
                var latestMinors   = SelectMax(orderedWithFramework, v => $"{v.Major}.{v.Minor}").ToList();
                var latestSpecific = entry.SpecificVersions.Length == 0
                    ? latestMajors
                    : SelectPackagesFromGlobs(orderedWithFramework, entry.SpecificVersions).ToList();

                _latestMinors.Write(entry, latestMinors, requiresDockerDependency);
                _latestMajors.Write(entry, latestMajors, requiresDockerDependency);
                _latestSpecific.Write(entry, latestSpecific, requiresDockerDependency);

                _strategyGenerator.Write(entry, null, requiresDockerDependency);
            }

            _latestMinors.Finish();
            _latestMajors.Finish();
            _latestSpecific.Finish();
            _strategyGenerator.Finish();
        }
Ejemplo n.º 2
0
        private async Task RunFileGeneratorWithPackageEntries(IEnumerable <PackageVersionEntry> entries, Solution solution)
        {
            _latestMinors.Start();
            _latestMajors.Start();
            _strategyGenerator.Start();

            foreach (var entry in entries)
            {
                var supportedTargetFrameworks = solution
                                                .GetProject(entry.SampleProjectName)
                                                .GetTargetFrameworks()
                                                .Select(x => (TargetFramework) new TargetFramework.TargetFrameworkTypeConverter().ConvertFrom(x));

                var packageVersions = await NuGetPackageHelper.GetNugetPackageVersions(entry);

                var orderedPackageVersions =
                    packageVersions
                    .Distinct()
                    .Select(versionText => new Version(versionText))
                    .OrderBy(v => v)
                    .ToList();

                var orderedWithFramework = (
                    from version in orderedPackageVersions
                    from framework in supportedTargetFrameworks
                    where IsSupported(entry, version.ToString(), framework)
                    select(version, framework))
                                           .ToList();

                // Always include some specific versions, to give us better coverage
                var alwaysIncludeVersions = entry.AlwaysIncludeVersions.Select(x => new Version(x));

                // Add the last for every minor
                var latestMinors = SelectMax(orderedWithFramework, v => $"{v.Major}.{v.Minor}", Array.Empty <Version>());
                var latestMajors = SelectMax(orderedWithFramework, v => v.Major, alwaysIncludeVersions);

                _latestMinors.Write(entry, latestMinors);
                _latestMajors.Write(entry, latestMajors);
                _strategyGenerator.Write(entry, null);
            }

            _latestMinors.Finish();
            _latestMajors.Finish();
            _strategyGenerator.Finish();
        }