dotnet/maui · error · Exception

Error: Couldn't find .exe file

Error message

Error: Couldn't find .exe file

What it means

Thrown after the build script searched both the project's local bin directory and the arcade artifacts fallback directory (../../artifacts/bin/) for any .exe file and found none. The script filters out createdump.exe, so only a real application binary will satisfy the search. This means the app was never compiled, was compiled to a different path, or the version/platform variables do not match the actual build output.

Source

Thrown at eng/devices/windows.cake:712

			if(PROJECT.FullPath.Contains("Graphics.DeviceTests"))
			{
				binDir = MakeAbsolute(new DirectoryPath(arcadeBin + "/Graphics.DeviceTests/" + CONFIGURATION + "/" + winVersion).Combine(DOTNET_PLATFORM));
			}
			if(PROJECT.FullPath.Contains("MauiBlazorWebView.DeviceTests"))
			{
				binDir = MakeAbsolute(new DirectoryPath(arcadeBin + "/MauiBlazorWebView.DeviceTests/" + CONFIGURATION + "/" + winVersion).Combine(DOTNET_PLATFORM));
			}
			if(PROJECT.FullPath.Contains("Essentials.DeviceTests"))
			{
				binDir = MakeAbsolute(new DirectoryPath(arcadeBin + "/Essentials.DeviceTests/" + CONFIGURATION + "/" + winVersion).Combine(DOTNET_PLATFORM));
			}

			Information("Looking for .exe in arcade binDir {0}", binDir);
			apps = GetFiles(binDir + "/*.exe").Where(c => !c.FullPath.EndsWith("createdump.exe"));
			if(apps.Count() == 0 )
			{
				Error("Error: Couldn't find .exe file");
				throw new Exception("Error: Couldn't find .exe file");
			}
		}
		TEST_APP = apps.First().FullPath;
	}

	if (string.IsNullOrEmpty(TEST_RESULTS))
	{
		TEST_RESULTS = TEST_APP + "-results";
	}

	// Device Tests
	if (string.IsNullOrEmpty(DEVICETEST_APP) )
	{
		if (string.IsNullOrEmpty(DEVICETEST_APP_PROJECT.FullPath))
		{
			throw new Exception("If no app was specified, an app must be provided.");
		}

View on GitHub (pinned to f377ff1c5e)

Solutions

  1. Run the full 'buildOnly' target first to ensure the .exe is produced: 'dotnet cake --target=buildOnly' then verify the .exe exists under the computed bin path.
  2. Verify CONFIGURATION, DOTNET_PLATFORM, DotnetVersion, and windowsVersion env vars match the actual build output directory name (the script prints 'BinDir: {path}' and 'Looking for .exe in arcade binDir {path}' — inspect those logs).
  3. If using arcade build output, confirm '../../artifacts/bin/Controls.TestCases.HostApp/{CONFIG}/{winVersion}/{platform}/' exists and contains an .exe.
  4. Set TEST_APP directly to the known .exe path to bypass the auto-discovery entirely.

Example fix

// before — variables don't match build output
set CONFIGURATION=Debug
set DOTNET_PLATFORM=win-x86
// after — align with actual TFM/RID used in build
set CONFIGURATION=Release
set DOTNET_PLATFORM=win-x64
set DotnetVersion=net9.0
set windowsVersion=10.0.19041.0
Defensive patterns

Strategy: validation

Validate before calling

// Verify the expected .exe exists before running tests
var binDir = Path.Combine(projectDir, "Controls.TestCases.HostApp", configuration, winVersion, platform);
var exe = Directory.GetFiles(binDir, "*.exe").FirstOrDefault(f => !f.EndsWith("createdump.exe"));
if (exe == null)
{
    Console.Error.WriteLine($"No .exe found in {binDir}. Build first with --target=buildOnly.");
    Environment.Exit(1);
}

Prevention

When it happens

Trigger: The SetupTestPaths task resolved TEST_APP_PROJECT to a valid project path, computed the expected bin directory from CONFIGURATION + DotnetVersion + windowsVersion + DOTNET_PLATFORM, called GetFiles('*.exe') on it (zero results), retried with the arcade artifacts path, and still got zero results.

Common situations: Building with a different RID or TFM than the test script expects (e.g. win-x64 vs win-arm64); CONFIGURATION mismatch (Debug vs Release); DotnetVersion or windowsVersion variable not matching the actual .NET SDK version string embedded in the output path; the HostApp project failed to build silently; running on a clean checkout where artifacts/ was never populated.

Related errors


AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13). Data as JSON: /api/errors/000388898203f042. Report an issue: GitHub.