{"record":{"id":"82cc1561421adf07","repo":"dotnet/maui","slug":"no-device-was-found-to-run-tests-on","errorCode":null,"errorMessage":"No device was found to run tests on.","messagePattern":"No device was found to run tests on\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/ios.cake","lineNumber":428,"sourceCode":"\n\ttry\n\t{\n\t\tDotNetTool(\"tool\", settings);\n\t}\n\tfinally\n\t{\n\t\tstring iosVersionToRun = version;\n\t\tstring deviceToRun = \"\";\n\n\t\tif (testDevice.Contains(\"device\"))\n\t\t{\n\t\t\tif (!string.IsNullOrEmpty(DEVICE_UDID))\n\t\t\t{\n\t\t\t\tdeviceToRun = DEVICE_UDID;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthrow new Exception(\"No device was found to run tests on.\");\n\t\t\t}\n\n\t\t\tiosVersionToRun = DEVICE_VERSION;\n\n\t\t\tInformation(\"The device to run tests: {0} {1}\", DEVICE_NAME, iosVersionToRun);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tvar UDID = GetUDID(testDevice, dotnetToolPath);\n\t\t\tvar sims = ListAppleSimulators();\n\n\t\t\tvar simXH = sims.Where(s => s.UDID == UDID).FirstOrDefault();\n\t\t\tif (simXH == null)\n\t\t\t{\n\t\t\t\tthrow new Exception(\"No simulator was found to run tests on.\");\n\t\t\t}\n\n\t\t\tdeviceToRun = simXH.UDID;","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/ios.cake#L410-L446","documentation":"Thrown in InstallIpa's finally block when testDevice contains 'device' and DEVICE_UDID is still empty after the install attempt. Because it sits in finally, it runs even if DotNetTool succeeded — meaning a device run cannot proceed to test execution without a UDID. This is the test-target-resolution counterpart to error 25's install-resolution.","triggerScenarios":"Physical-device target selected but DEVICE_UDID empty (connectToDevice not run or failed); device dropped after install but before the finally block resolved the run target; a target string containing 'device' used unintentionally.","commonSituations":"CI matrix leg targeting a device with none attached; local run that skipped Setup; intermittent USB disconnection between install and test phases.","solutions":["Ensure connectToDevice ran and resolved a device (check the 'The device to run tests' Information line earlier in the log).","Confirm the physical device stays connected through the whole install+test flow; reconnect if it drops.","Switch to a simulator target if no physical device is available.","Provide DEVICE_UDID explicitly via --udid when automatic detection is unreliable."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before the finally-block test-target resolution, ensure UDID is set\nif (testDevice.Contains(\"device\") && string.IsNullOrEmpty(DEVICE_UDID))\n    throw new Exception(\"DEVICE_UDID is empty before run-target resolution; device may have disconnected.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the device connected for the entire install+test flow.","Resolve DEVICE_UDID once in Setup and fail early rather than in a finally block.","Log the resolved device at each phase so a mid-run dropout is visible."],"tags":["cake","ios","xharness","physical-device","udid"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}