GitVersion CLI wrapper for Tamp.
| Package | GitVersion | Status |
|---|---|---|
Tamp.GitVersion.V6 |
6.x | live (0.1.0) |
Derives a SemVer product version from a GitFlow / GitHub-flow / trunk-based git history. Full CLI surface — outputs (json / file / buildserver / dotenv), single-variable extraction, custom format strings, config + override-config, assembly-info / project-file / WiX patching, and remote-repo args.
Requires Tamp.Core ≥ 1.0.0.
This was the first satellite released through the Tamp dogfood
pipeline — dotnet tamp Ci + dotnet tamp Push in
.github/workflows/release.yml.
GitVersion ships independently of .NET on its own cadence (V5 → V6 in 2024, patches every couple months). Per the satellite-repo convention, third-party tools with their own release schedule live outside main.
In your build script's Directory.Packages.props:
<PackageVersion Include="Tamp.GitVersion.V6" Version="0.1.0" />In build/Build.csproj:
<PackageReference Include="Tamp.GitVersion.V6" />using Tamp;
using Tamp.GitVersion.V6;
class Build : TampBuild
{
public static int Main(string[] args) => Execute<Build>(args);
[GitVersion] readonly GitVersionInfo Version = null!;
// ↑ GitVersion 6.x runs once at bind time; result is typed + cached.
// Default executable: dotnet-gitversion (then gitversion). Override
// via [GitVersion(Executable = "...")] if needed.
Target Image => _ => _.Executes(() =>
Docker.Build(s => s
.SetTag($"myapp:{Version.SemVer}-{Version.ShortSha}")));
}GitVersionInfo carries the full GitVersion 6.x output schema: Major /
Minor / Patch, MajorMinorPatch, SemVer, FullSemVer,
AssemblySemVer, InformationalVersion, BranchName / EscapedBranchName /
Sha / ShortSha, PreReleaseTag family, CommitsSinceVersionSource,
UncommittedChanges, CommitDate, plus a Raw dictionary that captures
any new fields the upstream CLI adds in patch versions.
This is the recommended shape for 0.2.0+ adopters. Lower-level
GitVersion.Run(...) CLI wrapper (below) stays available for adopters who
need the JSON output as a typed CommandPlan (build-graph traceability,
explicit working directory, etc).
using Tamp;
using Tamp.GitVersion.V6;
using Tamp.NetCli.V10;
class Build : TampBuild
{
public static int Main(string[] args) => Execute<Build>(args);
[NuGetPackage("GitVersion.Tool", Version = "6.7.0", ExecutableName = "dotnet-gitversion")]
readonly Tool GitVersionTool = null!;
string? _semVer;
Target ResolveVersion => _ => _
.Description("Run GitVersion once and stash the SemVer for later targets.")
.Executes(() =>
{
var plan = GitVersion.Run(GitVersionTool, s => s
.SetTargetPath(RootDirectory)
.SetShowVariable("SemVer"));
// The runner captures stdout; parse and stash on _semVer.
});
Target Compile => _ => _
.DependsOn(nameof(ResolveVersion))
.Executes(() => DotNet.Build(s => s
.SetProperty("Version", _semVer!)));
}- tamp — the core framework
- GitVersion docs — variable reference, branch config
MIT — same as tamp core. (GitVersion itself is MIT.)