SimpleBranchVersioning 0.3.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package SimpleBranchVersioning --version 0.3.1
NuGet\Install-Package SimpleBranchVersioning -Version 0.3.1
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="SimpleBranchVersioning" Version="0.3.1"> <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="SimpleBranchVersioning" Version="0.3.1" />
<PackageReference Include="SimpleBranchVersioning"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
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 SimpleBranchVersioning --version 0.3.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SimpleBranchVersioning, 0.3.1"
#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 SimpleBranchVersioning@0.3.1
#: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=SimpleBranchVersioning&version=0.3.1
#tool nuget:?package=SimpleBranchVersioning&version=0.3.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SimpleBranchVersioning
A .NET source generator that derives version information from Git branch names.
Why use SimpleBranchVersioning?
- Zero configuration - Install the package and it just works
- Convention-based - Version format follows your branch naming (e.g.,
release/v1.2.3becomes version1.2.3) - Automatic NuGet versioning - Package versions are set automatically based on the branch
- Compile-time generation - Version info is embedded as constants, no runtime Git dependencies
Installation
dotnet add package SimpleBranchVersioning
Usage
After installing the package, a static AppVersion class is automatically generated:
Console.WriteLine($"Version: {AppVersion.Version}");
Console.WriteLine($"Branch: {AppVersion.Branch}");
Console.WriteLine($"Commit: {AppVersion.CommitId}");
Version Format
| Branch Pattern | Version | PackageVersion |
|---|---|---|
release/v1.2.3 |
1.2.3 |
1.2.3+abc1234 |
release/1.2.3 |
1.2.3 |
1.2.3+abc1234 |
feature/login |
feature.login.abc1234 |
0.0.0-feature.login+abc1234 |
main |
main.abc1234 |
0.0.0-main+abc1234 |
Generated Class
public static class AppVersion
{
public const string Version = "..."; // Display version
public const string Branch = "..."; // Git branch name
public const string CommitId = "..."; // Short commit ID
public const string PackageVersion = "..."; // NuGet-compatible version
public const string AssemblyVersion = "..."; // Assembly version (X.Y.Z.0)
public const string FileVersion = "..."; // File version
public const string InformationalVersion = "..."; // Full version with metadata
}
Configuration
MSBuild Properties
| Property | Default | Description |
|---|---|---|
SetPackageVersionFromBranch |
true |
Automatically set NuGet package version from branch |
IncludeCommitIdMetadata |
true |
Include commit ID as build metadata in versions |
GenerateVersionFile |
false |
Generate version.json file during build |
Custom Class Name and Namespace
[assembly: SimpleBranchVersioning.AppVersionConfig(
Namespace = "MyApp.Versioning",
ClassName = "BuildInfo")]
CI/CD Integration
Enable GenerateVersionFile to output version information during build:
<PropertyGroup>
<GenerateVersionFile>true</GenerateVersionFile>
</PropertyGroup>
The file is written to $(OutputPath)/version.json.
Requirements
- .NET SDK 8.0 or later
- Git repository
License
This project is licensed under the MIT License - see the LICENSE file for details.
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.