コード例 #1
0
        public static async Task UpdateXml(string path, Configuration config)
        {
            var monoBranchHead = await GitHub.GetBranchHead(config.MonoRepo, config.MonoBranch, config.Verbose);

            if (String.IsNullOrEmpty(monoBranchHead))
            {
                // failed to get the branch head. Maybe MonoBranch is a commit sha
                monoBranchHead = config.MonoBranch;
            }

            var nugetExeSourceStream = await GitHub.GetRaw(config.MonoRepo, monoBranchHead, config.NuGetPyPath);

            var msbuildPySourceStream = await GitHub.GetRaw(config.MonoRepo, monoBranchHead, config.MSBuildPyPath);

            Console.WriteLine($"From mono repo {config.MonoRepo}, branch {config.MonoBranch} at commit {monoBranchHead}:");
            var nugetExeVersion = await GetRegexGroupAsString(nugetExeSourceStream, VersionUpdater.NuGetPyVersionRegexString);

            Console.WriteLine($"nuget.exe: {nugetExeVersion}");

            if (String.IsNullOrEmpty(config.MSBuildBranchOrSha))
            {
                config.MSBuildBranchOrSha = await GetRegexGroupAsString(msbuildPySourceStream, VersionUpdater.MSBuildPyRefRegexString);
            }
            Console.WriteLine($"{Environment.NewLine}From msbuild commit: {config.MSBuildBranchOrSha}");

            var detailsSourceStream = await GitHub.GetRaw(config.MSBuildRepo, config.MSBuildBranchOrSha, config.VersionDetailsPath);

            var versionsSourceStream = await GitHub.GetRaw(config.MSBuildRepo, config.MSBuildBranchOrSha, config.VersionsPath);

            Console.WriteLine($"-- SDKs --");
            var details = await VersionUpdater.ReadVersionDetails(detailsSourceStream);

            foreach (var kvp in details)
            {
                Console.WriteLine($"{kvp.Value.Name}: {kvp.Value.Version}");
            }

            Console.WriteLine();
            var versions = await VersionUpdater.ReadProps(versionsSourceStream, config.Verbose);

            if (versions.TryGetValue(VersionUpdater.RoslynPackagePropertyName, out string microsoftNetCompilersVersion))
            {
                Console.WriteLine($"Roslyn version in msbuild (only for building): {microsoftNetCompilersVersion}");
            }
            else
            {
                Console.WriteLine($"Roslyn version in msbuild (only for building): Not found!");
            }
        }
コード例 #2
0
        public static async Task UpdateXml(string path, Configuration config)
        {
            var toolsetBranchHead = await GitHub.GetBranchHead(config.ToolsetRepo, config.ToolsetBranch, config.Verbose);

            if (String.IsNullOrEmpty(toolsetBranchHead))
            {
                // failed to get the branch head. Maybe ToolsetBranch is a commit sha
                toolsetBranchHead = config.ToolsetBranch;
            }

            var versionsSourceStream = await GitHub.GetRaw(config.ToolsetRepo, toolsetBranchHead, config.VersionsPath);

            var detailsSourceStream = await GitHub.GetRaw(config.ToolsetRepo, toolsetBranchHead, config.VersionDetailsPath);

            var versionsTargetStream = await GitHub.GetRaw(config.MSBuildRepo, config.MSBuildBranch, config.VersionsPath);

            var packagesTargetStream = await GitHub.GetRaw(config.MSBuildRepo, config.MSBuildBranch, config.PackagesPath);

            var detailsTargetStream = await GitHub.GetRaw(config.MSBuildRepo, config.MSBuildBranch, config.VersionDetailsPath);

            var details = await VersionUpdater.ReadVersionDetails(detailsSourceStream);

            var versions = await VersionUpdater.ReadProps(versionsSourceStream, config.Verbose);

            versions.Remove("PackageVersionPrefix");
            versions.Remove("VersionPrefix");

            foreach (var detail in details.Values)
            {
                // translate Versions.Details name into props name
                var vkey = $"{detail.Name.Replace (".", "")}PackageVersion";

                if (versions.TryGetValue(vkey, out var version))
                {
                    if (config.Verbose)
                    {
                        Console.WriteLine($"{vkey}: {version} ====> {detail.Version} - {detail.Uri} - {detail.Sha}");
                    }
                }
                else
                {
                    if (config.Verbose)
                    {
                        Console.WriteLine($"No match for {vkey}");
                    }
                }
            }

            /* Alias nuget here?? */
            if (versions.TryGetValue("NuGetBuildTasksPackageVersion", out var ver))
            {
                versions ["NuGetPackagePackageVersion"] = ver;
            }
            if (versions.TryGetValue("MicrosoftNETCoreCompilersPackageVersion", out var roslyn_ver))
            {
                versions [VersionUpdater.RoslynPackagePropertyName] = roslyn_ver;
            }

            Stream detailsOutputStream  = null;
            Stream versionsOutputStream = null;
            Stream packagesOutputStream = null;

            if (path != null)
            {
                detailsOutputStream  = File.Create(Path.Combine(path, "eng/Version.Details.xml"));
                versionsOutputStream = File.Create(Path.Combine(path, "eng/Versions.props"));
                packagesOutputStream = File.Create(Path.Combine(path, "eng/Packages.props"));
            }

            var updatedVersions = await VersionUpdater.UpdateProps(versionsTargetStream, versionsOutputStream, versions, true);

            var updatedDetails = await VersionUpdater.UpdateDetails(detailsTargetStream, detailsOutputStream, details);

            var updatedPackages = await VersionUpdater.UpdateProps(packagesTargetStream, packagesOutputStream, versions, true);

            Console.WriteLine($"Bump versions from {config.ToolsetRepo} at {config.ToolsetBranch}");
            Console.WriteLine();
            Console.WriteLine($"Based on commit {toolsetBranchHead}");
            Console.WriteLine("```");
            foreach (var name in updatedDetails.Keys)
            {
                Console.WriteLine($"{name,-40}: {details[name].Version} (from {updatedDetails[name].Version})");
            }
            if (updatedVersions.TryGetValue(VersionUpdater.RoslynPackagePropertyName, out var compiler_ver))
            {
                Console.WriteLine($"{Environment.NewLine}{"Microsoft.Net.Compilers/Roslyn",-40}: {compiler_ver}");
            }
            Console.WriteLine("```");
        }