{"record":{"id":"2f711d14fb57a572","repo":"dotnet/maui","slug":"category-discovery-run-did-not-complete-successful","errorCode":null,"errorMessage":"Category discovery run did not complete successfully","messagePattern":"Category discovery run did not complete successfully","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/windows.cake","lineNumber":497,"sourceCode":"\t\t\t\t\tWarning($\"Failed to install dependency (exit code {depExit}): {dep}\");\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tWarning($\"Failed to install dependency: {dep}\");\n\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{","sourceCodeStart":479,"sourceCodeEnd":515,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/windows.cake#L479-L515","documentation":"Thrown in the packaged Controls test path when LaunchPackagedAndWait returns false for the category-discovery invocation (the app is launched with a -1 index to enumerate test categories). A false return means the packaged app either failed to activate/launch or did not exit within the 120-second timeout, so discovery never completed.","triggerScenarios":"The packaged WinUI app crashes on startup (e.g. missing runtime, unhandled init exception); app activation fails because the package family is not registered correctly; the discovery run exceeds the 120s timeout on a slow machine; the app hangs waiting for user input or a missing dependency.","commonSituations":"First launch after a fresh build where dependency installation was skipped/warned; a code change introducing a startup crash; slow CI runner hitting the 120s cap; package registration left in a bad state by a prior failed run.","solutions":["Launch the packaged app manually (or via the app's activation) and read any crash/Event Viewer entry to find the startup exception.","Check LaunchPackagedAndWait's own logging for whether it was a launch failure or a timeout, then raise the timeout or fix the crash accordingly.","Ensure all dependency MSIX frameworks installed successfully (review the dependency Warning lines); a missing framework causes immediate activation failure.","Re-run GenerateMsixCert and rebuild if the package signature/registration is suspect; unregister and reinstall the package."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before the discovery run, verify the package is registered and dependencies installed\nif (!IsPackageRegistered(PACKAGEID))\n    throw new Exception($\"Package {PACKAGEID} not registered; install failed earlier.\");","typeGuard":null,"tryCatchPattern":"try { if (!LaunchPackagedAndWait(args, \"discovery\", 120)) throw new Exception(\"Discovery launch/timeout — check activation and dependencies.\"); }\ncatch (Exception ex) { Error($\"Discovery failed: {ex.Message}\"); throw; }","preventionTips":["Confirm all dependency frameworks installed before launching the packaged app.","Capture Event Viewer app-crash entries when discovery fails to pinpoint the startup exception.","Keep the discovery timeout generous on slow CI runners."],"tags":["cake","windows","winui","packaged","app-activation","timeout"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}