Skip to content

[msbuild] Fix simulator OS version comparison in GetAvailableDevices#25931

Closed
Happypig375 wants to merge 2 commits into
dotnet:mainfrom
Happypig375:fix-simulator-os-version-comparison
Closed

[msbuild] Fix simulator OS version comparison in GetAvailableDevices#25931
Happypig375 wants to merge 2 commits into
dotnet:mainfrom
Happypig375:fix-simulator-os-version-comparison

Conversation

@Happypig375

Copy link
Copy Markdown
Member

Description

GetAvailableDevices.RunSimCtlAsync() uses the device type's MinRuntimeVersionString (e.g. "26.0.0") as the device's OS version when filtering against the app's MinimumOSVersion. This is wrong -- it should use the actual runtime version from simctl (e.g. "26.5").

The device type's minRuntimeVersionString represents the minimum OS version the physical device hardware supports, not the actual OS version running on the simulator. For example, an iPhone 17 Pro device type has minRuntimeVersionString: "26.0.0", but when created with the iOS 26.5 simulator runtime, its actual OS version is 26.5.

This causes dotnet run --device to reject every simulator device when the SDK version exceeds all device type minRuntimeVersionString values -- for example in Xcode 26.5 (iOS 26.5 SDK) where every device type has minRuntimeVersionString <= 26.3.

The fix

-                   if (Version.TryParse (deviceTypeInfo.MinRuntimeVersionString, out var parsedMinimumOSVersion))
+                   if (Version.TryParse (runtimeVersion, out var parsedMinimumOSVersion))
                        minimumOSVersion = parsedMinimumOSVersion;
-                   if (Version.TryParse (deviceTypeInfo.MaxRuntimeVersionString, out var parsedMaximumOSVersion))
-                       maximumOSVersion = parsedMaximumOSVersion;
+                   maximumOSVersion = new Version (65535, 255, 255);

This matches how RunDeviceCtlAsync() already handles physical devices:

Version.TryParse (device.OSVersion, out var minimumOSVersion);
var maximumOSVersion = new Version (65535, 255, 255);

Note: MaxRuntimeVersionString was always "65535.255.255" for every device type, so hardcoding the sentinel has no behavioral change but makes the code consistent with the physical device path.

Use the actual simulator runtime version from simctl (e.g. '26.5') instead
of the device type's MinRuntimeVersionString (e.g. '26.0.0') when filtering
simulators against the app's MinimumOSVersion.

The device type's minRuntimeVersion is the minimum OS version the device
hardware supports, not the actual OS version running on the simulator.
For example, an iPhone 17 Pro device type has minRuntimeVersionString 26.0.0,
but when created with an iOS 26.5 runtime, its actual OS version is 26.5.

This matches how RunDeviceCtlAsync handles physical devices:
    Version.TryParse (device.OSVersion, out var minimumOSVersion);
    var maximumOSVersion = new Version (65535, 255, 255);

Fixes the bug where dotnet run --device would reject every simulator device
with 'Device OS version X is lower than the app's minimum OS version Y'
when the SDK version (Y) exceeds all device type minRuntimeVersionString values.
Copilot AI review requested due to automatic review settings July 6, 2026 09:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes simulator OS version filtering in the GetAvailableDevices MSBuild task so dotnet run --device evaluates simulator eligibility using the simulator runtime’s actual OS version (from simctl runtimes) rather than the device type’s minimum-supported OS version.

Changes:

  • Use the simctl runtime version (runtimeVersion) when computing a simulator device’s minimumOSVersion.
  • Align simulator-path max OS handling with the device-path sentinel (65535.255.255).

Comment thread msbuild/Xamarin.MacDev.Tasks/Tasks/GetAvailableDevices.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@rolfbjarne

Copy link
Copy Markdown
Member

Continued in #25975.

@rolfbjarne rolfbjarne closed this Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Community contribution ❤

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants