{"record":{"id":"05503b357843cd29","repo":"dotnet/maui","slug":"test-categories-file-was-not-created-during-discov","errorCode":null,"errorMessage":"Test categories file was not created during discovery phase","messagePattern":"Test categories file was not created during discovery phase","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/windows.cake","lineNumber":501,"sourceCode":"\t\t\t}\n\t\t}\n\n\t\t// Install the DeviceTests app\n\t\tvar installExit = InstallAppxPackage(msixPath);\n\t\tif (installExit != 0) {\n\t\t\tthrow new Exception($\"Failed to install app MSIX (exit code {installExit}): {msixPath}\");\n\t\t}\n\n\t\tif (isControlsProjectTestRun)\n\t\t{\n\t\t\t// Start the app once to trigger the discovery of the test categories; we wait\n\t\t\t// for the actual app process to exit, then read the categories file.\n\t\t\tif (!LaunchPackagedAndWait($\"\\\"{testResultsFile}\\\" \\\"-1\\\"\", \"category discovery\", 120)) {\n\t\t\t\tthrow new Exception(\"Category discovery run did not complete successfully\");\n\t\t\t}\n\n\t\t\tif (!FileExists(testsToRunFile)) {\n\t\t\t\tthrow new Exception(\"Test categories file was not created during discovery phase\");\n\t\t\t}\n\n\t\t\tvar expectedCategories = System.IO.File.ReadAllLines(testsToRunFile);\n\t\t\tvar filteredCategories = FilterCategories(expectedCategories);\n\t\t\t\n\t\t\tif (filteredCategories.Length == 0) {\n\t\t\t\tInformation(\"No categories to run after applying filter. Skipping test execution.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tInformation($\"Will run {filteredCategories.Length} filtered categories out of {expectedCategories.Length} total\");\n\n\t\t\tfor (int i = 0; i < filteredCategories.Length; i++)\n\t\t\t{\n\t\t\t\tvar categoryName = filteredCategories[i];\n\t\t\t\t// Find the original index of this category in the expected categories\n\t\t\t\tvar originalIndex = Array.IndexOf(expectedCategories, categoryName);\n\t\t\t\tvar expectedResultFile = testResultsPath + $\"\\\\TestResults-{PACKAGEID.Replace(\".\", \"_\")}_{categoryName}.xml\";","sourceCodeStart":483,"sourceCodeEnd":519,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/windows.cake#L483-L519","documentation":"Thrown in the packaged Controls test path after the category-discovery app exited (LaunchPackagedAndWait returned true) but the testsToRunFile does not exist. The discovery invocation is supposed to make the app write its test-category list to a file; the file's absence means the app ran but never wrote the categories — typically a startup crash after activation, a wrong output path, or the discovery mode (-1) not being honored.","triggerScenarios":"The app activated and exited but crashed before reaching the category-enumeration/discovery code; testsToRunFile path resolves to a different location than the app writes to; the app launched in normal (not discovery) mode because the -1 argument was not parsed; write permissions on the results dir.","commonSituations":"A recent code change causing an early crash after activation; CONFIGURATION/results path mismatch so the file is written elsewhere; the app's discovery-mode argument contract changed but the script still passes -1; results dir on a path the packaged app (sandboxed) cannot write to.","solutions":["Compare the testsToRunFile path the script checks against the path the app actually writes (search the whole results dir and temp for any categories file).","Launch the packaged app with the discovery args manually and capture its output/Event Viewer to find where it crashes before writing.","Confirm the app's discovery-mode argument (-1) still matches the app's expected sentinel value after recent changes.","Verify the packaged app has write access to the testResultsPath (packaged apps have restricted write locations)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// After discovery exits, verify the file and report its expected path\nif (!FileExists(testsToRunFile))\n    throw new Exception($\"Discovery did not write {testsToRunFile}. Launch the packaged app manually to see the crash.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the testsToRunFile path consistent between the script and the app's discovery writer.","Ensure the packaged app can write to the results path (sandbox restrictions).","Confirm the -1 discovery sentinel matches the app's current contract."],"tags":["cake","windows","winui","packaged","test-categories","discovery"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}