System.Reflection.Assembly.Location might return an empty string in some scenarios
https://github.com/cake-build/cake/blob/d24d5eb2cb5712330066afa0c41229a73d0e4516/src/Cake.Core/CakeEnvironment.cs#L47C13-L47C71
var assembly = AssemblyHelper.GetExecutingAssembly();
var path = PathHelper.GetDirectoryName(assembly.Location);
Investigate if it could be using System.AppContext.BaseDirectory instead.