{"record":{"id":"000388898203f042","repo":"dotnet/maui","slug":"error-couldn-t-find-exe-file","errorCode":null,"errorMessage":"Error: Couldn't find .exe file","messagePattern":"Error: Couldn't find \\.exe file","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/windows.cake","lineNumber":712,"sourceCode":"\t\t\tif(PROJECT.FullPath.Contains(\"Graphics.DeviceTests\"))\n\t\t\t{\n\t\t\t\tbinDir = MakeAbsolute(new DirectoryPath(arcadeBin + \"/Graphics.DeviceTests/\" + CONFIGURATION + \"/\" + winVersion).Combine(DOTNET_PLATFORM));\n\t\t\t}\n\t\t\tif(PROJECT.FullPath.Contains(\"MauiBlazorWebView.DeviceTests\"))\n\t\t\t{\n\t\t\t\tbinDir = MakeAbsolute(new DirectoryPath(arcadeBin + \"/MauiBlazorWebView.DeviceTests/\" + CONFIGURATION + \"/\" + winVersion).Combine(DOTNET_PLATFORM));\n\t\t\t}\n\t\t\tif(PROJECT.FullPath.Contains(\"Essentials.DeviceTests\"))\n\t\t\t{\n\t\t\t\tbinDir = MakeAbsolute(new DirectoryPath(arcadeBin + \"/Essentials.DeviceTests/\" + CONFIGURATION + \"/\" + winVersion).Combine(DOTNET_PLATFORM));\n\t\t\t}\n\n\t\t\tInformation(\"Looking for .exe in arcade binDir {0}\", binDir);\n\t\t\tapps = GetFiles(binDir + \"/*.exe\").Where(c => !c.FullPath.EndsWith(\"createdump.exe\"));\n\t\t\tif(apps.Count() == 0 )\n\t\t\t{\n\t\t\t\tError(\"Error: Couldn't find .exe file\");\n\t\t\t\tthrow new Exception(\"Error: Couldn't find .exe file\");\n\t\t\t}\n\t\t}\n\t\tTEST_APP = apps.First().FullPath;\n\t}\n\n\tif (string.IsNullOrEmpty(TEST_RESULTS))\n\t{\n\t\tTEST_RESULTS = TEST_APP + \"-results\";\n\t}\n\n\t// Device Tests\n\tif (string.IsNullOrEmpty(DEVICETEST_APP) )\n\t{\n\t\tif (string.IsNullOrEmpty(DEVICETEST_APP_PROJECT.FullPath))\n\t\t{\n\t\t\tthrow new Exception(\"If no app was specified, an app must be provided.\");\n\t\t}\n","sourceCodeStart":694,"sourceCodeEnd":730,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/windows.cake#L694-L730","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","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).","If using arcade build output, confirm '../../artifacts/bin/Controls.TestCases.HostApp/{CONFIG}/{winVersion}/{platform}/' exists and contains an .exe.","Set TEST_APP directly to the known .exe path to bypass the auto-discovery entirely."],"exampleFix":"// before — variables don't match build output\nset CONFIGURATION=Debug\nset DOTNET_PLATFORM=win-x86\n// after — align with actual TFM/RID used in build\nset CONFIGURATION=Release\nset DOTNET_PLATFORM=win-x64\nset DotnetVersion=net9.0\nset windowsVersion=10.0.19041.0","handlingStrategy":"validation","validationCode":"// Verify the expected .exe exists before running tests\nvar binDir = Path.Combine(projectDir, \"Controls.TestCases.HostApp\", configuration, winVersion, platform);\nvar exe = Directory.GetFiles(binDir, \"*.exe\").FirstOrDefault(f => !f.EndsWith(\"createdump.exe\"));\nif (exe == null)\n{\n    Console.Error.WriteLine($\"No .exe found in {binDir}. Build first with --target=buildOnly.\");\n    Environment.Exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run buildOnly before testOnly.","Print and inspect the 'BinDir:' log line from the Cake script to verify the path.","Keep CONFIGURATION, DOTNET_PLATFORM, DotnetVersion, and windowsVersion consistent across build and test invocations.","Set TEST_APP to a known-good .exe path when iterating on tests to bypass path discovery."],"tags":["cake","build","windows","path-resolution","configuration"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}