Many applications display their commit ID alongside the version. VS Code is one such example:
Though I've only tried this on ASP.NET sites, this should be doable in most .NET applications.
To do this we create a pre-build event that'll execute a git command and save it in a text file. We then add that generated text file as a string resource. The resource can will now be accessible from
git rev-parse HEAD --short > "$(ProjectDir)\CurrentCommit.txt"
CurrentCommit.txtshould be created in the root of your project.
CurrentCommit.txtas a resource.
The contents of the generated file can now be accessed as: