Cake: Error: GitVersion: Could not locate executable.

Created on 8 Jul 2016  路  17Comments  路  Source: cake-build/cake

What You Are Seeing?

Error: GitVersion: Could not locate executable.

What is Expected?

GitVersion to return the correct version information for my repository

What version of Cake are you using?

Version 0.13.0+Branch.main.Sha.f7346f2a5fb4e19a24cf15780ce635529f921be4

Are you running on a 32 or 64 bit system?

64

What environment are you running on? Windows? Linux? Mac?

Windows 10

Are you running on a CI Server? If so, which one?

No

How Did You Get This To Happen? (Steps to Reproduce)

  • Download build.ps1 from cake repository
  • create a cake script with 1 task with the following lines
GitVersion assertedVersions = context.GitVersion(new GitVersionSettings
{
    OutputType = GitVersionOutput.Json,
});
  • Run build script

Note: I can run git commands from the command line without issue. It appears that the "bootstrapper" is not installing the gitversion.exe and instead is assuming that it is installed on the system already.

Output Log

Preparing to run build script...
Running build script...
Module directory does not exist.
Analyzing build script...
Analyzing E:/Projects/source/FrameworkAssets/CoreFunctionality/Mobile/build.cake...
Analyzing E:/Projects/source/FrameworkAssets/CoreFunctionality/Mobile/tools/versionUtils.cake...
Analyzing E:/Projects/source/FrameworkAssets/CoreFunctionality/Mobile/tools/settingsUtils.cake...
Processing build script...
Installing addins...
Package Cake.Json has already been installed.
The addin Cake.Json will reference Cake.Json.dll.
The addin Cake.Json will reference Newtonsoft.Json.dll.
Package Cake.Json has already been installed.
The addin Cake.Json will reference Cake.Json.dll.
The addin Cake.Json will reference Newtonsoft.Json.dll.
Creating script session...
Adding reference to mscorlib.dll...
Adding reference to System.dll...
Adding reference to System.Core.dll...
Adding reference to System.Data.dll...
Adding reference to System.Xml.dll...
Adding reference to System.Xml.Linq.dll...
Adding reference to Cake.Core.dll...
Adding reference to Cake.Common.dll...
Adding reference to Cake.exe...
Adding reference to Cake.Json.dll...
Adding reference to Newtonsoft.Json.dll...
Importing namespace Cake.Common...
Importing namespace Cake.Common.Build...
Importing namespace Cake.Common.Build.AppVeyor...
Importing namespace Cake.Common.Build.AppVeyor.Data...
Importing namespace Cake.Common.Build.Bitrise...
Importing namespace Cake.Common.Build.Bitrise.Data...
Importing namespace Cake.Common.Build.ContinuaCI...
Importing namespace Cake.Common.Build.ContinuaCI.Data...
Importing namespace Cake.Common.Build.Jenkins...
Importing namespace Cake.Common.Build.Jenkins.Data...
Importing namespace Cake.Common.Build.TravisCI...
Importing namespace Cake.Common.Build.TravisCI.Data...
Importing namespace Cake.Common.Diagnostics...
Importing namespace Cake.Common.IO...
Importing namespace Cake.Common.IO.Paths...
Importing namespace Cake.Common.Net...
Importing namespace Cake.Common.Security...
Importing namespace Cake.Common.Solution...
Importing namespace Cake.Common.Solution.Project...
Importing namespace Cake.Common.Solution.Project.Properties...
Importing namespace Cake.Common.Solution.Project.XmlDoc...
Importing namespace Cake.Common.Text...
Importing namespace Cake.Common.Tools...
Importing namespace Cake.Common.Tools.Cake...
Importing namespace Cake.Common.Tools.Chocolatey...
Importing namespace Cake.Common.Tools.Chocolatey.ApiKey...
Importing namespace Cake.Common.Tools.Chocolatey.Config...
Importing namespace Cake.Common.Tools.Chocolatey.Features...
Importing namespace Cake.Common.Tools.Chocolatey.Install...
Importing namespace Cake.Common.Tools.Chocolatey.Pack...
Importing namespace Cake.Common.Tools.Chocolatey.Pin...
Importing namespace Cake.Common.Tools.Chocolatey.Push...
Importing namespace Cake.Common.Tools.Chocolatey.Sources...
Importing namespace Cake.Common.Tools.Chocolatey.Upgrade...
Importing namespace Cake.Common.Tools.DNU...
Importing namespace Cake.Common.Tools.DNU.Build...
Importing namespace Cake.Common.Tools.DNU.Pack...
Importing namespace Cake.Common.Tools.DNU.Restore...
Importing namespace Cake.Common.Tools.DotCover...
Importing namespace Cake.Common.Tools.DotCover.Analyse...
Importing namespace Cake.Common.Tools.DotCover.Cover...
Importing namespace Cake.Common.Tools.DotNetCore...
Importing namespace Cake.Common.Tools.DotNetCore.Build...
Importing namespace Cake.Common.Tools.DotNetCore.Execute...
Importing namespace Cake.Common.Tools.DotNetCore.Pack...
Importing namespace Cake.Common.Tools.DotNetCore.Publish...
Importing namespace Cake.Common.Tools.DotNetCore.Restore...
Importing namespace Cake.Common.Tools.DotNetCore.Run...
Importing namespace Cake.Common.Tools.DotNetCore.Test...
Importing namespace Cake.Common.Tools.DupFinder...
Importing namespace Cake.Common.Tools.Fixie...
Importing namespace Cake.Common.Tools.GitLink...
Importing namespace Cake.Common.Tools.GitReleaseManager...
Importing namespace Cake.Common.Tools.GitReleaseManager.AddAssets...
Importing namespace Cake.Common.Tools.GitReleaseManager.Close...
Importing namespace Cake.Common.Tools.GitReleaseManager.Create...
Importing namespace Cake.Common.Tools.GitReleaseManager.Export...
Importing namespace Cake.Common.Tools.GitReleaseManager.Publish...
Importing namespace Cake.Common.Tools.GitReleaseNotes...
Importing namespace Cake.Common.Tools.GitVersion...
Importing namespace Cake.Common.Tools.ILMerge...
Importing namespace Cake.Common.Tools.ILRepack...
Importing namespace Cake.Common.Tools.InspectCode...
Importing namespace Cake.Common.Tools.MSBuild...
Importing namespace Cake.Common.Tools.MSTest...
Importing namespace Cake.Common.Tools.NSIS...
Importing namespace Cake.Common.Tools.NuGet...
Importing namespace Cake.Common.Tools.NuGet.Install...
Importing namespace Cake.Common.Tools.NuGet.Pack...
Importing namespace Cake.Common.Tools.NuGet.Push...
Importing namespace Cake.Common.Tools.NuGet.Restore...
Importing namespace Cake.Common.Tools.NuGet.SetApiKey...
Importing namespace Cake.Common.Tools.NuGet.SetProxy...
Importing namespace Cake.Common.Tools.NuGet.Sources...
Importing namespace Cake.Common.Tools.NuGet.Update...
Importing namespace Cake.Common.Tools.NUnit...
Importing namespace Cake.Common.Tools.OctopusDeploy...
Importing namespace Cake.Common.Tools.OpenCover...
Importing namespace Cake.Common.Tools.ReportGenerator...
Importing namespace Cake.Common.Tools.ReportUnit...
Importing namespace Cake.Common.Tools.Roundhouse...
Importing namespace Cake.Common.Tools.SignTool...
Importing namespace Cake.Common.Tools.SpecFlow...
Importing namespace Cake.Common.Tools.SpecFlow.StepDefinitionReport...
Importing namespace Cake.Common.Tools.SpecFlow.TestExecutionReport...
Importing namespace Cake.Common.Tools.TextTransform...
Importing namespace Cake.Common.Tools.VSTest...
Importing namespace Cake.Common.Tools.WiX...
Importing namespace Cake.Common.Tools.XBuild...
Importing namespace Cake.Common.Tools.XUnit...
Importing namespace Cake.Common.Xml...
Importing namespace Cake.Core...
Importing namespace Cake.Core.Diagnostics...
Importing namespace Cake.Core.IO...
Importing namespace Cake.Core.Scripting...
Importing namespace Cake.Json...
Importing namespace Newtonsoft.Json.Linq...
Importing namespace System...
Importing namespace System.Collections.Generic...
Importing namespace System.IO...
Importing namespace System.Linq...
Importing namespace System.Text...
Importing namespace System.Threading.Tasks...
Compiling build script...
Loading Settings: .\settings.json
Calculating Semantic Version
Error: Cake.Core.CakeException: GitVersion: Could not locate executable.
at Cake.Core.Tooling.Tool1.RunProcess(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings) at Cake.Core.Tooling.Tool1.Run(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings, Action1 postAction) at Cake.Common.Tools.GitVersion.GitVersionRunner.Run(GitVersionSettings settings) at Submission#0.VersionUtils.LoadVersionFromGit(ICakeContext context, String assemblyInfoFile) at Submission#0..ctor(Session session, Object& submissionResult) at Submission#0.<Factory>(Session session) at Roslyn.Scripting.CommonScriptEngine.Execute[T](String code, String path, DiagnosticBag diagnostics, Session session, Boolean isInteractive) at Roslyn.Scripting.Session.Execute(String code) at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary2 arguments)
at Cake.Commands.BuildCommand.Execute(CakeOptions options)
at Cake.CakeApplication.Run(CakeOptions options)
at Cake.Program.Main()

Most helpful comment

@Svetomechc my advice would be the following...

First of all, make use of the following module:

https://www.gep13.co.uk/blog/introducing-cake.dotnettool.module

Which will allow you to install .net Global Tools into your local tools folder. So, add the following to your build.cake file:

#module nuget:?package=Cake.DotNetTool.Module&version=0.1.0
#tool "dotnet:?package=GitVersion.Tool&version=4.0.1-beta1-51&prerelease"

This will download the Cake.DotNetTool.Module, and then when you run the build, it will download the GitVersion.Tool Global Tool into your local tools folder. NOTE: in order for this to work, you will need to do the following:

./build.sh --bootstrap
./build.sh

Then, in order to use that newly downloaded tool as part of the build, you will need to do something like the following:

  GitVersion(new GitVersionSettings{
    ToolPath = Context.Tools.Resolve("dotnet-gitversion") ?? Context.Tools.Resolve("dotnet-gitversion.exe")
  });

Depending on how exactly you are invoking GitVersion.

All 17 comments

Do you have GitVersion in path, if not try adding a #tool directive as suggested at
http://cakebuild.net/dsl/gitversion

I added this

``#tool nuget:?package=GitVersion.CommandLine

and it started working -- however I would think that since GitVersion is a "built in method" that should not be necessary, right?

@ravensorb The GitVersion alias is just a wrapper around the command line tool. No tools are shipped with Cake itself.

Then wouldn't it be better to move this to the "addin" section of the documentation? so that users would know there is more needed?

It's documented but can obviously be better documented.
We don't ship include MSBuild, XBuild, .Net framework. CoreCLR, XUnit, etc. either. Addins are assemblies that extend the DSL with new features abd/or tools.
Many have their tools already installed on their machines/agents for those that don't want/have that we provide the #tool directive or you can do it via your bootstrapper build.ps1|sh or a package.config together with Cake.

@ravensorb can you confirm exactly which section you mean? I thought that this:

http://cakebuild.net/dsl/gitversion

provided exactly the information that was needed.

@ravensorb I am going to go ahead and close this issue. If you feel additional work is required, please raise a separate issue on the website repository, as I suspect that this is where the work would require to be carried out.

Facing the same issue here:
image

This is the declaration at the top of my build.cake file:
#tool nuget:?package=GitVersion.CommandLine.DotNetCore&version=4.0.0

@Svetomechc that nupkg doesn't actually contain any .exe files. Instead, it contains the .net core dll, that would need to be invoked by the dotnet command line utility. As a result, the standard tool pre-processor directive isn't going to work.

@gep13 got it. Can you suggest any workaround?
I can't use GitVersion.CommandLine pacakge since it uses mono, and my build server doesn't have that.

@Svetomechc my advice would be the following...

First of all, make use of the following module:

https://www.gep13.co.uk/blog/introducing-cake.dotnettool.module

Which will allow you to install .net Global Tools into your local tools folder. So, add the following to your build.cake file:

#module nuget:?package=Cake.DotNetTool.Module&version=0.1.0
#tool "dotnet:?package=GitVersion.Tool&version=4.0.1-beta1-51&prerelease"

This will download the Cake.DotNetTool.Module, and then when you run the build, it will download the GitVersion.Tool Global Tool into your local tools folder. NOTE: in order for this to work, you will need to do the following:

./build.sh --bootstrap
./build.sh

Then, in order to use that newly downloaded tool as part of the build, you will need to do something like the following:

  GitVersion(new GitVersionSettings{
    ToolPath = Context.Tools.Resolve("dotnet-gitversion") ?? Context.Tools.Resolve("dotnet-gitversion.exe")
  });

Depending on how exactly you are invoking GitVersion.

@Svetomechc I have created an issue here:

https://github.com/cake-build/cake/issues/2387

Which should hopefully go into the 0.31.0 release of Cake, which would mean that the resolving of the tool part of the above shouldn't be required.

@gep13
Wow, this is so much more than I expected and so much faster than I expected. Thank you very much!
Will keep you posted if the workaround above works for me or not.

@Svetomechc you are very welcome.

@gep13
Your solution does indeed work, but there's a problem. build.sh is dependent on mono, not .NET Core
Can I circumvent that? Is there a .NET Core version of bootstrapper?

@Svetomechc here's an example of an .NET Core bootstrapper
https://github.com/csharpfritz/CoreWiki/blob/dev/build.sh

@Svetomechc said...
Your solution does indeed work

Glad to hear that you are up and running 馃槃

Was this page helpful?
0 / 5 - 0 ratings