When trying to use the Microsoft.TeamFoundation.Build.Activities.Git library I got the error
The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
The detailed error message said it was looking for version 0.13.0.0 of libGit2Sharp.dll. I noticed that through Nuget I had installed 0.14.0.0. I uninstalled it and reinstalled the proper version using Nuget. However the error persisted.
Given that this should work under TFS since it is used by the build system, I looked for, and found the version installed by TFS (at C:\Program Files\Microsoft Team Foundation Server 12.0\Tools). By using ILSpy I discovered that although it has the same version ID (0.13.0.0), it is in fact different as it has a newer dependency on file git2-msvstfs.dll.
Apparently Microsoft had a “buddy build” of libGit2Sharp.dll added to TFS 2013 with the same version number, instead of using the official download at https://github.com/libgit2/libgit2sharp. I later found out what the differences are, and will report that in another post.
When doing operations against TFS repos you should use the version of libGit2Sharp.dll shipped with TFS (installed under C:\Program Files\Microsoft Team Foundation Server 12.0\Tools), as Microsoft did private changes but did not change the version number.