I recently had to install GitVersion on an Ubuntu 16.04 server as part of provisioning a new build agent. I had to spend a bit of time figuring out how to do this, primarily due to the fragmented documentation. Hopefully these steps, all in one place, can help save others time.
GitVersion is written in C# .NET and as such requires the Mono framework in order to run on Linux.
$ sudo apt-get install mono-complete
GitVersion also requires
$ sudo apt-get install libcurl3
Download the latest release from GitHub:
$ wget https://github.com/GitTools/GitVersion/releases/download/v4.0.0-beta.12/GitVersion_4.0.0-beta0012.zip
Unzip it to a new folder:
$ unzip GitVersion_4.0.0-beta0012.zip -d GitVersion
At this point you should be able to run:
$ mono GitVersion/GitVersion.exe
However, it will error as it is not being executed from inside a git repository. In order to execute GitVersion in any folder we choose we need to add it to the path.
To make usage simple we will create a wrapper for GitVersion so that we can call it like any other standard Linux command.
First, change into the GitVersion folder:
$ cd GitVersion
Print the current working directory and then copy its value to your clipboard:
Open a new file using your text editor:
$ nano gitversion
Type or paste the following lines into the new file, substituting
current_working_directory with the contents of the
pwd command you previously copied.
Save the file and exit.
The final step in the install process is to add our wrapper to the
/usr/local/bin folder. This will allow us to execute
gitversion from any folder.
To add the wrapper to
/usr/local/bin create a symlink:
$ ln -S $(pwd)/gitversion /usr/local/bin/gitversion
Make sure to run the above command in the
GitVersion folder previously created to ensure the symlink is created with the correct path.
GitVersion should now be installed! To use it you simply execute
gitversion from within a git repository, passing any parameters you wish. Full docs on usage can be found here.