GitInfo 3.6.0

dotnet add package GitInfo --version 3.6.0
                    
NuGet\Install-Package GitInfo -Version 3.6.0
                    
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="GitInfo" Version="3.6.0">
  <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="GitInfo" Version="3.6.0" />
                    
Directory.Packages.props
<PackageReference Include="GitInfo">
  <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 GitInfo --version 3.6.0
                    
#r "nuget: GitInfo, 3.6.0"
                    
#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 GitInfo@3.6.0
                    
#: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=GitInfo&version=3.6.0
                    
Install as a Cake Addin
#tool nuget:?package=GitInfo&version=3.6.0
                    
Install as a Cake Tool

EULA OSS GitHub

Git Info from MSBuild, C# and VB

A fresh and transparent approach to Git information retrieval from MSBuild and Code without using any custom tasks or compiled code and tools, obscure settings, format strings, etc.

Open Source Maintenance Fee

To ensure the long-term sustainability of this project, users of this package who generate revenue must pay an Open Source Maintenance Fee. While the source code is freely available under the terms of the License, this package and other aspects of the project require adherence to the Maintenance Fee.

To pay the Maintenance Fee, become a Sponsor at the proper OSMF tier. A single fee covers all of Devlooped packages.

Usage

By default, if the containing project is a C#, F# or VB project, a compile-time generated source file will contain all the git information and can be accessed from anywhere within the assembly, as constants in a ThisAssembly (partial) class and its nested Git static class:

Console.WriteLine(ThisAssembly.Git.Commit);

NOTE: you may need to close and reopen the solution in order for Visual Studio to refresh intellisense and show the ThisAssembly type the first time after installing the package.

By default, GitInfo will also set $(Version) and $(PackageVersion) which the .NET SDK uses for deriving the AssemblyInfo, FileVersion and InformationalVersion values, as well as for packing. This default version is formatted from the following populated MSBuild properties: $(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch)$(GitSemVerDashLabel)+$(GitBranch).$(GitCommit).

So, straight after install and build/pack, you will get some versioning in place 😃.

Alternatively, you can opt-out of this default versioning by setting GitVersion=false in your project file, if you want to just leverage the Git information and/or version properties/constants yourself:

<PropertyGroup>
  <GitVersion>false</GitVersion>
</PropertyGroup>

This allows you to use the provided constants to build any versioning attributes you want, with whatever information you want, without resorting to settings, format strings or anything, just plain code:

C#:

[assembly: AssemblyVersion(ThisAssembly.Git.BaseVersion.Major + "." + ThisAssembly.Git.BaseVersion.Minor + "." + ThisAssembly.Git.BaseVersion.Patch)]

[assembly: AssemblyFileVersion(ThisAssembly.Git.SemVer.Major + "." + ThisAssembly.Git.SemVer.Minor + "." + ThisAssembly.Git.SemVer.Patch)]

[assembly: AssemblyInformationalVersion(
    ThisAssembly.Git.SemVer.Major + "." +
    ThisAssembly.Git.SemVer.Minor + "." +
    ThisAssembly.Git.Commits + "-" +
    ThisAssembly.Git.Branch + "+" +
    ThisAssembly.Git.Commit)]

F#:

module AssemblyInfo

open System.Reflection

[<assembly: AssemblyVersion(ThisAssembly.Git.BaseVersion.Major + "." + ThisAssembly.Git.BaseVersion.Minor + "." + ThisAssembly.Git.BaseVersion.Patch)>]

[<assembly: AssemblyFileVersion(ThisAssembly.Git.SemVer.Major + "." + ThisAssembly.Git.SemVer.Minor + "." + ThisAssembly.Git.SemVer.Patch)>]

[<assembly: AssemblyInformationalVersion(
    ThisAssembly.Git.SemVer.Major + "." +
    ThisAssembly.Git.SemVer.Minor + "." +
    ThisAssembly.Git.Commits + "-" +
    ThisAssembly.Git.Branch + "+" +
    ThisAssembly.Git.Commit)>]

do ()

VB:

<Assembly: AssemblyVersion(ThisAssembly.Git.BaseVersion.Major + "." + ThisAssembly.Git.BaseVersion.Minor + "." + ThisAssembly.Git.BaseVersion.Patch)>

<Assembly: AssemblyFileVersion(ThisAssembly.Git.SemVer.Major + "." + ThisAssembly.Git.SemVer.Minor + "." + ThisAssembly.Git.SemVer.Patch)>

<Assembly: AssemblyInformationalVersion(
    ThisAssembly.Git.SemVer.Major + "." +
    ThisAssembly.Git.SemVer.Minor + "." +
    ThisAssembly.Git.Commits + "-" +
    ThisAssembly.Git.Branch + "+" +
    ThisAssembly.Git.Commit)>

NOTE: when generating your own assembly version attributes, you will need to turn off the corresponding assembly version attribute generation from the .NET SDK, by setting the relevant properties to false: GenerateAssemblyVersionAttribute, GenerateAssemblyFileVersionAttribute and GenerateAssemblyInformationalVersionAttribute.

You can also just build your own versioning logic in a target that depends on GitInfo using plain MSBuild:

<PropertyGroup>
  <GitVersion>false</GitVersion> 
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="GitInfo" PrivateAssets="all" />
</ItemGroup>

<Target Name="PopulateInfo" DependsOnTargets="GitVersion" BeforeTargets="GetAssemblyVersion;GenerateNuspec;GetPackageContents">
  <PropertyGroup>
    <Version>$(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch)$(GitSemVerDashLabel)+$(GitBranch).$(GitCommit)</Version>
    <PackageVersion>$(Version)</PackageVersion>
    <RepositoryBranch>$(GitBranch)</RepositoryBranch>
    <RepositoryCommit>$(GitCommit)</RepositoryCommit>
    <SourceRevisionId>$(GitBranch) $(GitCommit)</SourceRevisionId>
  </PropertyGroup>
</Target>

NOTE: because the provided properties are populated via targets that need to run before they are available, you cannot use the GitInfo-provided properties in a PropertyGroup at the project level. You can only use them from within a target that in turn depends on the relevant target from GitInfo (typically, GitVersion as shown above, if you consume the SemVer properties).

Because this information is readily available whenever you build the project, you never depend on CI build scripts that generate versions for you, and you can always compile locally exactly the same version of an assembly that was built by a CI server.

You can read more about this project at the GitInfo announcement blog post.

Details

Exposes the following information for use directly from any MSBuild target that depends on the GitInfo target:

  $(GitRepositoryUrl)
  $(GitBranch)
  $(GitCommit)
  $(GitCommitDate)
  $(GitCommits)
  $(GitTag)
  $(GitBaseTag)
  $(GitBaseVersionMajor)
  $(GitBaseVersionMinor)
  $(GitBaseVersionPatch)
  $(GitSemVerMajor)
  $(GitSemVerMinor)
  $(GitSemVerPatch)
  $(GitSemVerLabel)
  $(GitSemVerDashLabel)
  $(GitSemVerSource)
  $(GitIsDirty)

For C#, F# and VB, constants are generated too so that the same information can be accessed from code:

  ThisAssembly.Git.RepositoryUrl
  ThisAssembly.Git.Branch
  ThisAssembly.Git.Commit
  ThisAssembly.Git.Commits
  ThisAssembly.Git.Tag
  ThisAssembly.Git.BaseTag
  ThisAssembly.Git.BaseVersion.Major
  ThisAssembly.Git.BaseVersion.Minor
  ThisAssembly.Git.BaseVersion.Patch
  ThisAssembly.Git.SemVer.Major
  ThisAssembly.Git.SemVer.Minor
  ThisAssembly.Git.SemVer.Patch
  ThisAssembly.Git.SemVer.Label
  ThisAssembly.Git.SemVer.DashLabel
  ThisAssembly.Git.SemVer.Source
  ThisAssembly.Git.IsDirty

Goals

  • No compiled code or tools → 100% transparency
  • Trivially added/installed via a NuGet package
  • No format strings or settings to learn
  • Simple well-structured .targets file with plain MSBuild and no custom tasks
  • Optional embedding of Git info in assembly metadata
  • Optional use of Git info to build arbitrary assembly/file version information, both in C# as well as VB.
  • Trivially modified/improved generated code by just adjusting a C# or F# or VB template included in the NuGet package
  • 100% incremental build-friendly and high-performing (all proper Inputs/Outputs in place, smart caching of Git info, etc.)

Sponsors

Clarius Org MFB Technologies, Inc. DRIVE.NET, Inc. Keith Pickford Thomas Bolon Kori Francis Uno Platform Reuben Swartz Jacob Foshee alternate text is missing from this package README image Eric Johnson David JENNI Jonathan Charley Wu Ken Bonny Simon Cropp agileworks-eu Zheyu Shen Vezel ChilliCream 4OTC Vincent Limo Jordan S. Jones domischell Justin Wendlandt Adrian Alonso Michael Hagedorn alternate text is missing from this package README image torutek mccaffers

Sponsor this project  

Learn more about GitHub Sponsors

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages (11)

Showing the top 5 NuGet packages that depend on GitInfo:

Package Downloads
Aqovia.PactProducerVerifier.AspNetCore

Pact Producer Test for aspnet core sites

BizStream.NET.Sdk

Core build and release configuration for packages and libraries distributed by BizStream.

Zooqle.Net

A .NET Standard library for searching torrents on Zooqle.

PH.RollingZipRotatorLog4net

A netstandard2.0 Zip utility to perform a very simple log4net file rotation. The code perform a zip-compression on every log-rotated file and delete it, watching on log4net output directory reading settings of appenders.

SPLogging.Web

Web Log helper ใช้สำหรับ ช่วยเก็บค่า sesion และ อื่นๆ สำหรับ log

GitHub repositories (39)

Showing the top 20 popular GitHub repositories that depend on GitInfo:

Repository Stars
gitextensions/gitextensions
Git Extensions is a standalone UI tool for managing git repositories. It also integrates with Windows Explorer and Microsoft Visual Studio (2015/2017/2019).
kurrent-io/KurrentDB
KurrentDB is a database that's engineered for modern software applications and event-driven architectures. Its event-native design simplifies data modeling and preserves data integrity while the integrated streaming engine solves distributed messaging challenges and ensures data consistency.
xamarin/Xamarin.Forms
Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
dotnet/macios
.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
ClassIsland/ClassIsland
一款适用于班级多媒体屏幕的课表信息显示工具,可以一目了然地显示各种信息。
VitalElement/AvalonStudio
Cross platform IDE and Shell
CollapseLauncher/Collapse
An Advanced Launcher for miHoYo/HoYoverse Games
fullstackproltd/AspNetCoreSpa
Asp.Net 7.0 & Angular 15 SPA Fullstack application with plenty of examples. Live demo:
alanmcgovern/monotorrent
The official repository for MonoTorrent, a bittorrent library for .NET
ubisoft/Sharpmake
Sharpmake is an open-source C#-based solution for generating project definition files, such as Visual Studio projects and solutions, GNU makefiles, Xcode projects, etc.
BedrockLauncher/BedrockLauncher
wabbajack-tools/wabbajack
An automated Modlist installer for various games.
dotnet/Microsoft.Maui.Graphics
An experimental cross-platform native graphics library.
dotnet/Microsoft.Maui.Graphics.Controls
Experimental Microsoft.Maui.Graphics.Controls - Build drawn controls (Cupertino, Fluent and Material)
SteeltoeOSS/Samples
Steeltoe samples and reference application collection
nkdAgility/azure-devops-migration-tools
Azure DevOps Migration Tools allow you to migrate Teams, Backlogs, Work Items, Tasks, Test Cases, and Plans & Suits from one Project to another in Azure DevOps / TFS both within the same Organisation, and between Organisations.
bitfaster/BitFaster.Caching
High performance, thread-safe in-memory caching primitives for .NET
couchbase/couchbase-lite-net
A lightweight, document-oriented (NoSQL), syncable database engine for .NET
jackBonadies/SeekerAndroid
Android client for the Soulseek peer-to-peer network
tukasa0001/TownOfHost
Host only mod for Among Us.
Version Downloads Last Updated
3.6.0 498 10/17/2025
3.5.0 528,465 11/2/2024
3.3.5 477,469 5/13/2024
3.3.4 243,896 2/15/2024
3.3.3 473,506 8/30/2023
3.3.2 811 8/30/2023
3.3.1 16,974 8/11/2023
3.3.0 4,048 8/11/2023
3.2.0 5,590 8/11/2023
2.3.0 1,177,407 11/18/2022
2.2.1 22,691 11/16/2022
2.2.0 1,660,859 8/26/2021
2.1.2 1,608,572 9/24/2020
2.1.1 1,146 9/24/2020
2.0.40 2,979 9/24/2020
2.0.39 4,137 9/23/2020
2.0.38 1,910 9/21/2020
2.0.37 1,340 9/20/2020
2.0.36 980 9/20/2020
2.0.35 968 9/20/2020
2.0.34 12,419 9/11/2020
2.0.33 13,167 8/28/2020
2.0.32 917 8/28/2020
2.0.31 69,114 8/3/2020
2.0.30 15,039 7/27/2020
2.0.29 70,576 7/22/2020
2.0.28 1,139 7/22/2020
2.0.27 948 7/22/2020
2.0.26 492,475 12/16/2019
2.0.25 1,917 12/13/2019
2.0.21 94,445 10/15/2019
2.0.20 681,632 11/13/2018
2.0.19 12,942 11/2/2018
2.0.18 105,909 9/26/2018
2.0.17 23,278 9/10/2018
2.0.16 1,302 9/10/2018
2.0.15 85,883 8/14/2018
2.0.14 3,605 8/3/2018
2.0.11 344,981 6/1/2018
2.0.10 34,121 2/21/2018
2.0.9 2,059 2/20/2018
2.0.8 17,790 11/30/2017
2.0.7 7,856 11/30/2017
2.0.6 20,793 10/22/2017
2.0.5 1,642 10/19/2017
2.0.3 8,932 10/18/2017
2.0.2 4,017 9/29/2017
2.0.1 90,158 8/24/2017
2.0.0 4,589 8/16/2017
1.1.72 2,702 8/7/2017
1.1.71 6,765 7/10/2017
1.1.70 1,574 7/10/2017
1.1.68 1,753 7/7/2017
1.1.67 1,865 7/4/2017
1.1.66 1,974 6/23/2017
1.1.65 1,867 6/15/2017
1.1.63 1,931 6/15/2017
1.1.62 3,215 6/4/2017
1.1.61 5,030 5/31/2017
1.1.60 2,393 5/16/2017
1.1.59 16,545 5/11/2017
1.1.58 1,858 5/5/2017
1.1.57 1,771 4/29/2017
1.1.56 1,585 4/28/2017
1.1.55 9,185 4/26/2017
1.1.54 1,592 4/26/2017
1.1.53 2,397 4/12/2017
1.1.48 3,961 2/10/2017
1.1.47 1,556 2/10/2017
1.1.45 3,205 1/27/2017
1.1.44 1,561 1/27/2017
1.1.43 1,667 1/25/2017
1.1.41 1,616 1/25/2017
1.1.40 1,971 1/6/2017
1.1.39 1,935 12/26/2016
1.1.38 2,379 12/26/2016
1.1.37 1,852 12/12/2016
1.1.35 2,664 11/29/2016
1.1.34 1,956 11/24/2016
1.1.31 2,343 9/13/2016
1.1.30 1,640 9/13/2016
1.1.29 2,308 9/3/2016
1.1.28 2,966 8/10/2016
1.1.27 1,733 8/8/2016
1.1.26 1,620 8/8/2016
1.1.25 3,255 7/28/2016
1.1.24 1,893 7/28/2016
1.1.23 1,901 7/28/2016
1.1.22 1,987 7/28/2016
1.1.20 2,667 6/4/2016
1.1.19 1,744 5/29/2016
1.1.17 1,648 5/26/2016
1.1.15 3,637 5/23/2016
1.1.14 2,848 5/22/2016
1.1.13 1,746 5/19/2016
1.1.12 3,805 4/24/2016
1.1.10 1,847 4/8/2016
1.1.9 1,692 3/31/2016
1.1.8 1,657 3/31/2016
1.1.7 1,647 3/31/2016
1.1.5 2,192 3/16/2016
1.1.4 1,672 3/16/2016
1.1.2 1,716 3/14/2016
1.1.1 2,461 3/12/2016
1.1.0 1,963 3/11/2016
1.0.64-pre 1,332 3/12/2016
1.0.63-pre 1,407 3/12/2016
1.0.62-pre 1,680 3/12/2016
1.0.61-pre 1,697 3/12/2016
1.0.60-pre 1,365 3/11/2016
1.0.59-pre 1,691 3/11/2016
1.0.58-pre 1,363 3/11/2016
1.0.56-pre 3,671 1/9/2016
1.0.55-pre 2,268 1/7/2016
1.0.54-pre 2,063 12/14/2015
1.0.53-pre 1,700 12/10/2015
1.0.52-pre 1,927 12/10/2015
1.0.51-pre 1,704 12/10/2015
1.0.50-pre 1,724 12/9/2015
1.0.49-pre 3,217 10/5/2015
1.0.48-pre 1,741 10/3/2015
1.0.47-pre 1,566 9/2/2015
1.0.46-pre 1,431 9/2/2015
1.0.45-pre 1,490 9/1/2015
1.0.44-pre 1,426 9/1/2015
1.0.43-pre 1,429 9/1/2015
1.0.42-pre 1,437 8/18/2015
1.0.41-pre 1,772 8/7/2015
1.0.40-pre 1,486 7/19/2015
1.0.39-pre 1,422 7/10/2015
1.0.38-pre 1,447 6/26/2015
1.0.37-pre 1,383 6/26/2015
1.0.36-pre 1,410 6/26/2015
1.0.35-pre 1,431 6/26/2015
1.0.34-pre 1,461 6/24/2015
1.0.33-pre 1,495 6/17/2015
1.0.31-pre 1,456 6/16/2015
1.0.30-pre 1,432 6/16/2015
1.0.29-pre 1,415 6/16/2015
1.0.28-pre 1,416 6/16/2015
1.0.27-pre 1,432 6/16/2015
1.0.26-pre 1,472 6/15/2015
1.0.25-pre 1,454 6/14/2015
1.0.24-pre 1,475 6/11/2015
1.0.23-pre 1,423 6/8/2015
1.0.22-pre 1,426 6/8/2015
1.0.21-pre 1,438 6/8/2015
1.0.20-pre 1,465 6/8/2015
1.0.19-pre 1,434 6/8/2015
1.0.18-pre 1,443 6/8/2015
1.0.16-pre 1,436 6/5/2015
1.0.15-pre 1,480 6/5/2015
1.0.14-pre 1,480 6/4/2015
1.0.11-pre 1,403 6/3/2015
1.0.10-pre 1,429 6/3/2015
1.0.9-pre 1,449 6/3/2015
1.0.8-pre 1,425 6/3/2015
1.0.7-pre 1,480 6/3/2015
1.0.6-pre 1,405 6/3/2015
1.0.5-pre 1,392 6/3/2015
1.0.4-pre 1,433 6/3/2015
1.0.3-pre 1,411 6/3/2015
1.0.1-pre 1,433 6/3/2015
1.0.0 1,923 2/22/2016
1.0.0-pre 1,397 5/26/2015
0.0.196 854 10/14/2020
0.0.195 844 10/5/2020
0.0.194 27,145 9/24/2020