Exemple #1
0
        public static BuildTargetResult GenerateVersions(BuildTargetContext c)
        {
            var commitCount = GitUtils.GetCommitCount();
            var commitHash  = GitUtils.GetCommitHash();

            var branchInfo   = ReadBranchInfo(c, Path.Combine(c.BuildContext.BuildDirectory, "branchinfo.txt"));
            var buildVersion = new BuildVersion()
            {
                Major         = int.Parse(branchInfo["MAJOR_VERSION"]),
                Minor         = int.Parse(branchInfo["MINOR_VERSION"]),
                Patch         = int.Parse(branchInfo["PATCH_VERSION"]),
                ReleaseSuffix = branchInfo["RELEASE_SUFFIX"],
                CommitCount   = commitCount
            };

            var hostVersion = new HostVersion()
            {
                CommitCount = commitCount
            };

            c.BuildContext["BuildVersion"] = buildVersion;
            c.BuildContext["HostVersion"]  = hostVersion;
            c.BuildContext["CommitHash"]   = commitHash;
            c.BuildContext["SharedFrameworkNugetVersion"] = buildVersion.NetCoreAppVersion;

            c.Info($"Building Version: {buildVersion.SimpleVersion} (NuGet Packages: {buildVersion.NuGetVersion})");
            c.Info($"From Commit: {commitHash}");

            return(c.Success());
        }
Exemple #2
0
        public static BuildTargetResult GenerateVersions(BuildTargetContext c)
        {
            var gitResult = Cmd("git", "rev-list", "--count", "HEAD")
                            .CaptureStdOut()
                            .Execute();

            gitResult.EnsureSuccessful();
            var commitCount = int.Parse(gitResult.StdOut);

            gitResult = Cmd("git", "rev-parse", "HEAD")
                        .CaptureStdOut()
                        .Execute();
            gitResult.EnsureSuccessful();
            var commitHash = gitResult.StdOut.Trim();

            var branchInfo   = ReadBranchInfo(c, Path.Combine(c.BuildContext.BuildDirectory, "branchinfo.txt"));
            var buildVersion = new BuildVersion()
            {
                Major         = int.Parse(branchInfo["MAJOR_VERSION"]),
                Minor         = int.Parse(branchInfo["MINOR_VERSION"]),
                Patch         = int.Parse(branchInfo["PATCH_VERSION"]),
                ReleaseSuffix = branchInfo["RELEASE_SUFFIX"],
                CommitCount   = commitCount
            };

            var hostVersion = new HostVersion()
            {
                CommitCount = commitCount
            };

            c.BuildContext["BuildVersion"] = buildVersion;
            c.BuildContext["HostVersion"]  = hostVersion;
            c.BuildContext["CommitHash"]   = commitHash;
            c.BuildContext["SharedFrameworkNugetVersion"] = buildVersion.NetCoreAppVersion;

            c.Info($"Building Version: {buildVersion.SimpleVersion} (NuGet Packages: {buildVersion.NuGetVersion})");
            c.Info($"From Commit: {commitHash}");

            return(c.Success());
        }