public static string Version(this ICakeContext context) { StringBuilder Message = new StringBuilder(); GitVersionSettings buildServerSettings = new GitVersionSettings { OutputType = GitVersionOutput.BuildServer, UpdateAssemblyInfo = true }; SetGitVersionPath(buildServerSettings); // Ran twice because the result is empty when using buildserver mode but we need to output to TeamCity // and use the result context.GitVersion(buildServerSettings); GitVersionSettings localSettings = new GitVersionSettings(); SetGitVersionPath(localSettings); var versionResult = context.GitVersion(localSettings); //Information("AssemblySemVer: " + versionResult.AssemblySemVer); Message.Append("AssemblySemVer: " + versionResult.AssemblySemVer + "\n"); // Convert 12.1.3.4 to 1201030004 etc. string paddedVersionNumber = string.Join("", versionResult.AssemblySemVer.Split('.').Select(s => s.PadLeft(2, '0')).ToArray()) + "00"; //Information("PaddedVersionNumber: " + paddedVersionNumber); BuildNumber = versionResult.SemVer; BranchName = versionResult.BranchName; Message.Append("BranchName updated: " + BranchName + "\n"); Message.Append("BuildNumber updated: " + BuildNumber + "\n"); //Information("BuildNumber updated: " + BuildNumber); return(Message.ToString()); }