diff --git a/src/Cake.Common/Tools/Cake/CakeRunner.cs b/src/Cake.Common/Tools/Cake/CakeRunner.cs index af00fc034f..e1fd072cec 100644 --- a/src/Cake.Common/Tools/Cake/CakeRunner.cs +++ b/src/Cake.Common/Tools/Cake/CakeRunner.cs @@ -22,6 +22,7 @@ public sealed class CakeRunner : Tool private readonly ICakeEnvironment _environment; private readonly IFileSystem _fileSystem; private readonly IGlobber _globber; + private static readonly IEnumerable _executingAssemblyToolPaths = new FilePath[] { System.Reflection.Assembly.GetEntryAssembly().Location }; /// /// Initializes a new instance of the class. @@ -151,18 +152,18 @@ protected override IEnumerable GetAlternativeToolPaths(CakeSettings se if (!_environment.Platform.IsUnix()) { - return Enumerable.Empty(); + return _executingAssemblyToolPaths; } if (!_fileSystem.Exist(new DirectoryPath(homebrewCakePath))) { - return Enumerable.Empty(); + return _executingAssemblyToolPaths; } var files = _globber.GetFiles(homebrewCakePath + "**/Cake.exe"); var filePaths = files as FilePath[] ?? files.ToArray(); return filePaths.Length == 0 - ? Enumerable.Empty() + ? _executingAssemblyToolPaths : filePaths.OrderByDescending(f => f.FullPath); } }