Instructions for Git Users
1. Download MSBuildVersioning.dll
and save it into your solution folder. It doesn't matter where - you can put it in the root folder of your solution, or you might already have a folder for third-party DLLs.
2. In your C# project's Properties
folder, create files VersionInfo.base.cs
3. Add the following lines to VersionInfo.base.cs
(leave VersionInfo.cs empty).
When your project builds, VersionInfo.base.cs will be copied over top of VersionInfo.cs, with $REVNUM$ replaced by your Git revision number and $DIRTY$ replaced with 1 if you have uncommitted changes, or 0 if the working copy is clean. See what other
you can use.
4. Make your source control include VersionInfo.base.cs
5. Set the "Build Action" to None
6. Remove the AssemblyVersion and AssemblyFileVersion lines from your project's
7. Close your solution, and open your project's csproj
file in a text editor. At the bottom of the file, uncomment the BeforeBuild and AfterBuild targets. Add the following UsingTask and GitVersionFile elements:
<UsingTask TaskName="GitVersionFile" AssemblyFile="..\MSBuildVersioning.dll" />
- "..\MSBuildVersioning.dll" assumes you put MSBuildVersioning.dll in the root folder of your solution. Adjust this path if you put it somewhere else.
8. Reopen your solution, and build!
- You can customize your version format by using different
tokens in VersionInfo.base.cs.
- You can embed Git information into other parts of your program, such as your
You will need to have git.exe
on your path. If you don't have that, you may want to install
Git for Windows
and enable the "Run Git from the Windows Command Prompt" option.