コード例 #1
0
        public override bool Execute()
        {
            var allRepoProps = new Dictionary <string, string>();

            foreach (var dependency in Dependencies.Select(dep =>
                                                           new {
                Name = dep.GetMetadata("Name"),
                Version = dep.GetMetadata("ExactVersion"),
                Sha = dep.GetMetadata("Sha"),
                Uri = dep.GetMetadata("Uri")
            }))
            {
                string         repoName       = GetDefaultRepoNameFromUrl(dependency.Uri);
                string         safeRepoName   = repoName.Replace("-", "");
                string         propsPath      = Path.Combine(SourceBuildMetadataDir, $"{repoName}.props");
                DerivedVersion derivedVersion = GetVersionInfo(dependency.Version, "0");
                var            repoProps      = new Dictionary <string, string>
                {
                    ["GitCommitHash"]          = dependency.Sha,
                    ["OfficialBuildId"]        = derivedVersion.OfficialBuildId,
                    ["OutputPackageVersion"]   = dependency.Version,
                    ["PreReleaseVersionLabel"] = derivedVersion.PreReleaseVersionLabel,
                    ["IsStable"] = string.IsNullOrWhiteSpace(derivedVersion.PreReleaseVersionLabel) ? "true" : "false",
                };
                WritePropsFile(propsPath, repoProps);
                allRepoProps[$"{safeRepoName}GitCommitHash"]        = dependency.Sha;
                allRepoProps[$"{safeRepoName}OutputPackageVersion"] = dependency.Version;
            }
            string allRepoPropsPath = Path.Combine(SourceBuildMetadataDir, "AllRepoVersions.props");

            Log.LogMessage(MessageImportance.Normal, $"[{DateTimeOffset.Now}] Writing all repo versions to {allRepoPropsPath}");
            UpdatePropsFile(allRepoPropsPath, allRepoProps);

            return(!Log.HasLoggedErrors);
        }
コード例 #2
0
        private void WriteSourceBuildMetadata(string sourceBuildMetadataPath, string repoGitDir, Dependency dependency)
        {
            string         propsPath      = Path.Combine(sourceBuildMetadataPath, $"{GetRepoNameOrDefault(dependency)}.props");
            string         commitCount    = GetCommitCount(repoGitDir, dependency.Sha);
            DerivedVersion derivedVersion = GetVersionInfo(dependency.Version, commitCount);
            var            repoProps      = new Dictionary <string, string>
            {
                ["GitCommitHash"]          = dependency.Sha,
                ["GitCommitCount"]         = commitCount,
                ["GitCommitDate"]          = GetCommitDate(repoGitDir, dependency.Sha),
                ["OfficialBuildId"]        = derivedVersion.OfficialBuildId,
                ["OutputPackageVersion"]   = dependency.Version,
                ["PreReleaseVersionLabel"] = derivedVersion.PreReleaseVersionLabel
            };

            WritePropsFile(propsPath, repoProps);
        }
コード例 #3
0
 private void WriteSourceBuildMetadata(string sourceBuildMetadataPath, string repoGitDir, Dependency dependency)
 {
     foreach (string repoName in GetRepoNamesOrDefault(dependency))
     {
         string         propsPath      = Path.Combine(sourceBuildMetadataPath, $"{repoName}.props");
         string         commitCount    = GetCommitCount(repoGitDir, dependency.Sha);
         DerivedVersion derivedVersion = GetVersionInfo(dependency.Version, commitCount);
         var            repoProps      = new Dictionary <string, string>
         {
             ["GitCommitHash"]          = dependency.Sha,
             ["GitCommitCount"]         = commitCount,
             ["GitCommitDate"]          = GetCommitDate(repoGitDir, dependency.Sha),
             ["OfficialBuildId"]        = derivedVersion.OfficialBuildId,
             ["OutputPackageVersion"]   = dependency.Version,
             ["PreReleaseVersionLabel"] = derivedVersion.PreReleaseVersionLabel,
             ["IsStable"] = string.IsNullOrWhiteSpace(derivedVersion.PreReleaseVersionLabel) ? "true" : "false",
         };
         WritePropsFile(propsPath, repoProps);
     }
 }