dotnet/maui · error · Exception

No device was found to run tests on.

Error message

No device was found to run tests on.

What it means

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.

Source

Thrown at eng/devices/ios.cake:428

	try
	{
		DotNetTool("tool", settings);
	}
	finally
	{
		string iosVersionToRun = version;
		string deviceToRun = "";

		if (testDevice.Contains("device"))
		{
			if (!string.IsNullOrEmpty(DEVICE_UDID))
			{
				deviceToRun = DEVICE_UDID;
			}
			else
			{
				throw new Exception("No device was found to run tests on.");
			}

			iosVersionToRun = DEVICE_VERSION;

			Information("The device to run tests: {0} {1}", DEVICE_NAME, iosVersionToRun);
		}
		else
		{
			var UDID = GetUDID(testDevice, dotnetToolPath);
			var sims = ListAppleSimulators();

			var simXH = sims.Where(s => s.UDID == UDID).FirstOrDefault();
			if (simXH == null)
			{
				throw new Exception("No simulator was found to run tests on.");
			}

			deviceToRun = simXH.UDID;

View on GitHub (pinned to f377ff1c5e)

Solutions

  1. Ensure connectToDevice ran and resolved a device (check the 'The device to run tests' Information line earlier in the log).
  2. Confirm the physical device stays connected through the whole install+test flow; reconnect if it drops.
  3. Switch to a simulator target if no physical device is available.
  4. Provide DEVICE_UDID explicitly via --udid when automatic detection is unreliable.
Defensive patterns

Strategy: validation

Validate before calling

// Before the finally-block test-target resolution, ensure UDID is set
if (testDevice.Contains("device") && string.IsNullOrEmpty(DEVICE_UDID))
    throw new Exception("DEVICE_UDID is empty before run-target resolution; device may have disconnected.");

Prevention

When it happens

Trigger: 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.

Common situations: CI matrix leg targeting a device with none attached; local run that skipped Setup; intermittent USB disconnection between install and test phases.

Related errors


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