MahApps/MahApps.Metro · error · Exception
File not found: {fileName}
Error message
File not found: {fileName} What it means
ExecuteProcess (build.cake:399) is the Cake helper that wraps every external tool invocation (e.g. XAML Styler, code signing). It first checks FileExists(fileName) and throws an Exception with the resolved path if the executable cannot be found. This fails the task before the process is ever started.
Source
Thrown at build.cake:403
.AppendSwitchQuoted("--file-digest", "sha256")
.AppendSwitchQuoted("--description", description)
.AppendSwitchQuoted("--description-url", "https://github.com/MahApps/MahApps.Metro")
.Append("--no-page-hashing")
.AppendSwitchQuoted("--timestamp-rfc3161", "http://timestamp.digicert.com")
.AppendSwitchQuoted("--timestamp-digest", "sha256")
.AppendSwitchQuoted("--azure-key-vault-url", vurl)
.AppendSwitchQuotedSecret("--azure-key-vault-client-id", vcid)
.AppendSwitchQuotedSecret("--azure-key-vault-tenant-id", vctid)
.AppendSwitchQuotedSecret("--azure-key-vault-client-secret", vcs)
.AppendSwitchQuotedSecret("--azure-key-vault-certificate", vc)
);
}
void ExecuteProcess(FilePath fileName, ProcessArgumentBuilder arguments, string workingDirectory = null)
{
if (!FileExists(fileName))
{
throw new Exception($"File not found: {fileName}");
}
var processSettings = new ProcessSettings
{
RedirectStandardOutput = true,
RedirectStandardError = true,
Arguments = arguments
};
if (!string.IsNullOrEmpty(workingDirectory))
{
processSettings.WorkingDirectory = workingDirectory;
}
Information($"Arguments: {arguments.RenderSafe()}");
using(var process = StartAndReturnProcess(fileName, processSettings))
{View on GitHub (pinned to 72099e310b)
Solutions
- Confirm the tool binary actually exists at the path printed in the message; if not, run the Cake tool-installing setup (the #tool directives / bootstrap) so tools are restored into ./tools.
- Check the variable that computes fileName (e.g. styler tool resolution) and fix the directory or version it points to.
- Run a clean restore target first (e.g. build.ps1 -Target Restore) before the target that needs the tool.
- Verify the tool is compatible with the current OS/architecture (some tools are Windows-only).
Example fix
// before: tool path unresolved
ExecuteProcess("./tools/xamlstyler", args);
// after: ensure the #tool restore ran, then resolve explicitly
#tool "nuget:?package=XamlStyler&version=..."
var styler = Context.Tools.Resolve("XamlStyler.exe")
?? throw new Exception("XamlStyler tool not restored; run -Target Restore");
ExecuteProcess(styler, args); Defensive patterns
Strategy: validation
Validate before calling
// Resolve and validate the tool path before calling ExecuteProcess
var toolPath = Context.Tools.Resolve("XamlStyler.exe");
if (toolPath is null || !FileExists(toolPath)) {
throw new Exception($"Tool not restored: run -Target Restore first. Expected XamlStyler.exe");
}
ExecuteProcess(toolPath, args); Prevention
- Always run the tool-restore target (#tool directives / bootstrap) before targets that invoke external tools.
- Pin tool versions in #tool nuget directives so restores are reproducible.
- Use Cake's Context.Tools.Resolve(...) and assert non-null before invoking a process.
- Document each external tool and the variable that locates it.
When it happens
Trigger: Calling ExecuteProcess(styler, ...) when the styler tool path resolves to a non-existent file; calling SignFiles when the signing tool path is missing; any task that invokes an external binary whose path was not restored/downloaded.
Common situations: A required tool (e.g. XAMLStyler, the Azure signing tool, GitVersion) was not installed or its expected install path changed. The tool path variable was not set. A package restore step that downloads the tool was skipped or failed silently. Running on a fresh checkout without the ./tools restore step.
Related errors
- Errors occurred:{Environment.NewLine} {string.Join(Environme
- Exit code: {exitCode}
- {repoName} will only build on Windows because it's not possi
- The GITHUB_TOKEN environment variable is not defined.
AI-assisted analysis of MahApps/MahApps.Metro@72099e310b (2026-08-13).
Data as JSON: /api/errors/129412ede5efd5a4.
Report an issue: GitHub.