0

I am using MSBuildCommunityTasks to retrieve the git commit hash at build time:

<GitVersion LocalPath="$(MSBuildProjectDirectory)">
  <Output TaskParameter="CommitHash" PropertyName="GitRevision" />
</GitVersion>

MSBUILD executes this task as expected on my local machine but fails on when Team Foundation Service's Hosted Build Controller executes it:

SalesApplication.Versioning.csproj (81): The "GitVersion" task failed unexpectedly.
System.Exception: Could not find git.exe.  Looked in PATH locations and various common folders inside Program Files.

Apparently the hosted build controllers employed by TFService do not afford direct access to git.exe according to the list of installed packages: http://listofsoftwareontfshostedbuildserver.azurewebsites.net/

How can MSBUILD retrieve git commit information on the hosted build controller?

TheFastCat
  • 3,134
  • 4
  • 22
  • 32
  • 2
    You could check in the Git binaries and reference them from your source control mapping. – jessehouwing Nov 11 '13 at 22:12
  • Good suggestion! I did just this; unfortunately in the process I found an issue within MSBuild community tasks in which GitVersion's LocalPath is ignored : https://github.com/loresoft/msbuildtasks/issues/100 ; fixed the issue on a local fork and initiated a pull request with the fix. – TheFastCat Nov 12 '13 at 03:14

2 Answers2

2

This actually helped. I basically had to reninstall Git with the option

Use Git from the Windows Command Prompt

enter image description here

Rwiti
  • 1,056
  • 1
  • 13
  • 31
1

This was due to MSBuild failed to locate git.exe location (ie. C:\Program Files\Git\bin). You can check whether your java.library.path (Manage Jenkins > System Info) contains git path or not if not you need to add git location to your Path variable then reboot your server to take effect. Hope this help.

**In Windows environment, java.library.path is same with PATH variable.

yancyn
  • 959
  • 9
  • 10