Timtek.GitFlowVersioning 0.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package Timtek.GitFlowVersioning --version 0.0.3
                    
NuGet\Install-Package Timtek.GitFlowVersioning -Version 0.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Timtek.GitFlowVersioning" Version="0.0.3">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Timtek.GitFlowVersioning" Version="0.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Timtek.GitFlowVersioning">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Timtek.GitFlowVersioning --version 0.0.3
                    
#r "nuget: Timtek.GitFlowVersioning, 0.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Timtek.GitFlowVersioning@0.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Timtek.GitFlowVersioning&version=0.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Timtek.GitFlowVersioning&version=0.0.3
                    
Install as a Cake Tool

Timtek.GitFlowVersioning

A minimal, opinionated GitFlow-focussed versioning utility for .NET MSBuild projects.

What It Does

Timtek.GitFlowVersioning automatically computes semantic version numbers from your Git history during the build, so you never need to maintain version numbers by hand. It reads your branch name and the most recent version tag to produce a fully populated set of version properties including Version, PackageVersion, AssemblyVersion, FileVersion, and InformationalVersion.

This solution is deliberately constrained in scope. It is designed to work for:

  • Standard GitFlow workflows using main, develop, release/*, and hotfix/* branches.
  • .NET SDK-style projects using MSBuild version properties and the dotnet CLI.
  • TeamCity and GitHub Actions CI environments.

This supports our approach to versioning and release management across our projects without the overhead and complexity of more widely-scoped tools. If your workflow or requirements differ, there are other excellent Git-based versioning tools available that may be a better fit.

How It Works

The package ships as a development dependency containing an MSBuild task. At build time the task:

  1. Inspects the current Git branch and the most recent git describe tag.
  2. Classifies the branch using GitFlow conventions (main, develop, release/*, hotfix/*, or feature/other).
  3. Computes a SemVer 2.0 version based on the branch type and the number of commits since the last tag.
  4. Sets the standard MSBuild version properties so the compiler, assembly info, and NuGet pack all receive the correct version automatically.
  5. Generates a GitVersionInformation class in the intermediate output containing the full set of version variables. Because this class does not exist until compilation, IDE tooling may report errors and direct access would require reflection. The GitVersion class in the TA.Utils.Core NuGet package provides a safe, easy-to-use wrapper for runtime access to these values.

Branch Versioning Strategy

Branch Pre-release label Example
main / master (none — stable release) 1.2.3
develop alpha 1.3.0-alpha.12
release/* beta 1.3.0-beta.4
hotfix/* beta 1.2.4-beta.1
Any other (feature/*, etc.) alpha 1.3.0-alpha.7

The base version is taken from the most recent Git tag matching *.*.* (with or without a v prefix). The commit distance from that tag is used as the pre-release number or added to the patch component on main.

Getting Started

Install the package into your project:

dotnet add package Timtek.GitFlowVersioning

That's it. The next dotnet build or dotnet pack will automatically compute and apply versions. No configuration is required for standard GitFlow workflows.

Tagging a Release

Create a tag on main when you want to mark a release:

git tag 1.0.0
git push origin 1.0.0

Tags can optionally use a v prefix (v1.0.0).

Accessing Version Information at Runtime

The generated GitVersionInformation class is internal and does not exist until compilation, so referencing it directly in your source code will produce build errors in the IDE. Accessing it via reflection is possible but clumsy and error-prone.

Instead, use the GitVersion class from the TA.Utils.Core NuGet package, which provides a safe wrapper:

var version = GitVersion.GitInformationalVersion;
Console.WriteLine(version);  // "1.2.3+5.Branch.main.Sha.a1b2c3d..."

CI Support

The task automatically emits service messages when running under supported CI environments:

  • GitHub Actions — sets ::notice annotations and writes semver, fullSemVer, and informationalVersion to $GITHUB_OUTPUT.
  • TeamCity — sets the build number and exposes version parameters via ##teamcity messages.

Disabling Versioning

Set the MSBuild property GitFlowVersioningEnabled to false in your project or on the command line:

<PropertyGroup>
  <GitFlowVersioningEnabled>false</GitFlowVersioningEnabled>
</PropertyGroup>

Requirements

  • Git must be available on the PATH.
  • The repository must have at least one commit.

Fault Tolerance

The task is designed to never fail a build. If it cannot compute a version for any reason (e.g. Git is not installed, the directory is not a repository, or the history is unreadable), it logs an MSBuild warning and substitutes a placeholder version of 0.0.0-unversioned.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 119 3/5/2026 1.0.0 is deprecated because it has critical bugs.
0.0.3 146 3/6/2026
0.0.1 94 3/5/2026