-
Notifications
You must be signed in to change notification settings - Fork 554
[msbuild/dotnet] Add support for listing the devices and simulators available to run on. #24542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…mulators available to run on. This consists of two parts: * Add an MSBuild target that lists all the available devices (`ComputeAvailableDevices`), by returning them in a `$(Devices)` item group. * Add support for the `$(Device)` property to specify the device or simulator to use. Regarding the device list, we'll filter the returned list by: * Platform (don't return an Apple TV simulator for an iOS app). * Minimum OS version (not return an iOS 18.0 device when the app's minimum OS version is 26.0). * Only devices that are actually available, as reported by `devicectl` or `simctl`. References: * dotnet/android#10576 * https://github.com/dotnet/sdk/blob/2b9fc02a265c735f2132e4e3626e94962e48bdf5/documentation/specs/dotnet-run-for-maui.md Fixes #23995.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds support for listing available iOS and tvOS devices and simulators that can be used with dotnet run. It implements the ComputeAvailableDevices MSBuild target and adds support for the $(Device) property to specify which device or simulator to use when running applications.
Changes:
- Adds new
GetAvailableDevicesMSBuild task that queriesdevicectlandsimctlfor available devices/simulators - Introduces
JsonExtensionsutility class for parsing JSON output from Apple command-line tools - Reorganizes targets into separate Mobile and Desktop target files for better modularity
- Updates documentation to describe the new
Deviceproperty andComputeAvailableDevicestarget
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/common/JsonExtensions.cs | New JSON helper extension methods for parsing devicectl/simctl output |
| msbuild/Xamarin.MacDev.Tasks/Tasks/GetAvailableDevices.cs | Main implementation that queries and filters devices based on platform, OS version, and runtime identifier |
| tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GetAvailableDevicesTest.cs | Comprehensive unit tests with test JSON data |
| dotnet/targets/Microsoft.Sdk.Mobile.targets | Extracted mobile-specific targets including the new ComputeAvailableDevices target |
| dotnet/targets/Microsoft.Sdk.Desktop.targets | Extracted desktop-specific targets for macOS/MacCatalyst |
| dotnet/targets/Xamarin.Shared.Sdk.targets | Refactored to import mobile/desktop targets conditionally |
| msbuild/Xamarin.MacDev.Tasks/Tasks/GetMlaunchArguments.cs | Refactored product family string constants for consistency |
| docs/building-apps/build-targets.md | Documents the new ComputeAvailableDevices target |
| docs/building-apps/build-properties.md | Documents the new Device property |
| tests/dotnet/MultiFrameworkApp/* | New multi-framework test application |
| tests/common/shared-dotnet.mk | Updated to use Device property instead of _DeviceName |
| msbuild/Xamarin.Shared/Xamarin.Shared.targets | Moved _AppBundleManifestPath property definition |
| msbuild/Xamarin.MacDev.Tasks/Xamarin.MacDev.Tasks.csproj | Added JsonExtensions.cs to project |
| dotnet/Makefile | Added new target files to build |
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GetAvailableDevicesTest.cs
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| <_RelativeMlaunchPath Condition="'$(_RelativeMlaunchPath)' == ''">$(RelativeMlaunchPath)</_RelativeMlaunchPath> | ||
|
|
||
| <!-- Try to keep _DeviceName working for a while yet --> | ||
| <Device Condition="'$(Device)' == ''">$(_DeviceName)</Device> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…24279-main-2026-01-22
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…24279-main-2026-01-22
✅ [CI Build #0a2ab67] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #0a2ab67] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [CI Build #0a2ab67] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build #0a2ab67] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build #0a2ab67] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build #0a2ab67] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
💻 [CI Build #0a2ab67] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build #0a2ab67] Tests on macOS arm64 - Mac Tahoe (26) passed 💻✅ All tests on macOS arm64 - Mac Tahoe (26) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #0a2ab67] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 117 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
This consists of two parts:
ComputeAvailableDevices), by returning them in a$(Devices)item group.$(Device)property to specify the device or simulator to use.Regarding the device list, we'll filter the returned list by:
devicectlorsimctl.References:
$(Device)andComputeAvailableDevicesMSBuild target android#10576Fixes #23995.
Backport of #24279.