Repository navigation
[release/11.0.1xx] [dotnet] Add DeployToDevice MSBuild target for 'dotnet run' support - #26830
rolfbjarne wants to merge 18 commits into
Conversation
Implement the DeployToDevice target as specified in the dotnet run for MAUI spec. This target deploys an already-built app to a device or simulator without rebuilding, enabling the 'dotnet run --no-build' workflow. The target: - Reuses existing GetMlaunchArguments task to compute install arguments - Supports both physical devices (--installdev) and simulators (--installsim) - Accepts the $(Device) property for device selection - Depends on ComputeAvailableDevices for device discovery - Only applies to mobile platforms (iOS/tvOS) via SdkIsMobile condition Fixes #24382 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Cover both a device RID and a simulator RID, asserting the computed mlaunch install arguments (--installdev vs --installsim), and add a test asserting a clear error is raised when the app hasn't been built. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Clean the test project's RID-specific outputs before building so stale ready-to-run state from earlier test cases cannot cause missing assembly failures. Also treat an empty MlaunchInstallArguments property as unavailable, allowing the expected no-device error path on CI agents without attached devices. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d07a98d3-3b68-4bfa-8c58-a4e0f8f87d7a
Run the Clean target through dotnet build so the selected runtime identifier is restored before cleanup. A direct dotnet clean fails when the shared test project's existing assets file was generated for another RID. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d07a98d3-3b68-4bfa-8c58-a4e0f8f87d7a
Exercise both physical-device and simulator installation arguments for tvOS, matching the platform coverage of the DeployToDevice target. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d07a98d3-3b68-4bfa-8c58-a4e0f8f87d7a
Run hot reload configuration validation before DeployToDevice installs the app, while retaining the post-deployment startup-hook copy step. Document the public DeployToDevice target, its Device selection property, and its use by dotnet run --no-build. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d07a98d3-3b68-4bfa-8c58-a4e0f8f87d7a
Add a deterministic physical-device case that confirms the Device property is forwarded to mlaunch as --devname. Revert the unrelated macOS CoreCLR app-size baseline update because the deploy target is mobile-only. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d07a98d3-3b68-4bfa-8c58-a4e0f8f87d7a
Use a deterministic mlaunch stub for explicit device selection and assert that DeployToDevice executes it with the computed installation arguments. This keeps the no-device tolerance while ensuring removal of the deployment Exec task is detected. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d07a98d3-3b68-4bfa-8c58-a4e0f8f87d7a
Restore the public GetMlaunchArguments.Help parameter and ShowRunHelp target so existing MSBuild integrations continue to work. Keep the compatibility path conditioned away from normal deployment and run argument computation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d07a98d3-3b68-4bfa-8c58-a4e0f8f87d7a
Restore the discarded-device help test alongside the compatibility implementation so changes to the public Help path continue to be validated. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d07a98d3-3b68-4bfa-8c58-a4e0f8f87d7a
Restrict the executable mlaunch test stub to non-Windows hosts so the cross-platform test assembly satisfies CA1416 while retaining deterministic deployment execution coverage on macOS CI agents. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d07a98d3-3b68-4bfa-8c58-a4e0f8f87d7a
Prevent parameterized DeployToDevice cases from cleaning and building the same referenced project directories concurrently, which caused intermittent MSB3231 failures in CI. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d07a98d3-3b68-4bfa-8c58-a4e0f8f87d7a
Inspect the deployment binlog and assert that Build, Compile, and CoreCompile are not executed. This protects DeployToDevice's no-build contract from future dependency regressions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d07a98d3-3b68-4bfa-8c58-a4e0f8f87d7a
Override the mobile Run target so direct MSBuild invocations deploy before computing launch arguments. The .NET SDK's deploy-then-compute orchestration remains separate and therefore does not deploy twice. Add a stub-backed regression test that verifies direct Run performs exactly one install followed by one launch. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d07a98d3-3b68-4bfa-8c58-a4e0f8f87d7a
Keep DeployToDevice and ComputeRunArguments dependencies on the later Windows Run override while retaining remote Exec session handling. Allow an explicitly selected device to proceed when discovery returns no devices, and cover the behavior at the task level. This makes direct Run regression coverage deterministic without requiring connected hardware. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d07a98d3-3b68-4bfa-8c58-a4e0f8f87d7a
Prevent deployment tests from cleaning shared referenced-project outputs while preserving RID-specific cleanup for the app under test. This avoids races with other fixtures building MonoTouch.Dialog concurrently. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d07a98d3-3b68-4bfa-8c58-a4e0f8f87d7a
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The target changes break physical-device hot reload, allow manifest compilation during no-build deployment, and invoke mlaunch during simulator help requests.
Review effort: Balanced
Findings: 3
Open (3)
What changed in this PR
Backports deployment-only support to .NET 11 Apple tooling, enabling dotnet run --no-build for iOS and tvOS.
Changes:
- Adds device and simulator deployment and connects it to
Run. - Allows explicit device selection without discovery results.
- Documents the target and adds deployment regression tests.
| File | Description |
|---|---|
| tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GetMlaunchArgumentsTaskTests.cs | Tests explicit device selection. |
| tests/dotnet/UnitTests/MlaunchTest.cs | Tests deployment, missing bundles, and install-before-launch ordering. |
| msbuild/Xamarin.MacDev.Tasks/Tasks/GetMlaunchArguments.cs | Allows explicit devices without discovery results. |
| msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Common.After.targets | Adds deployment and argument preparation before remote execution. |
| dotnet/targets/Microsoft.Sdk.Mobile.targets | Adds deployment targets and updates launch dependencies. |
| docs/building-apps/build-targets.md | Documents DeployToDevice. |
| Name="_PrepareRunMobile" | ||
| BeforeTargets="ComputeRunArguments" | ||
| DependsOnTargets="_ValidateHotReloadConfiguration;_InstallMobile;_CopyStartupHooksToDevice;ComputeMlaunchRunArguments" | ||
| DependsOnTargets="_ValidateHotReloadConfiguration;ComputeMlaunchRunArguments" |
✅ 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 |
|
Copilot might be right that this breaks hot reload on device, some more testing is needed. |
🔥 [CI Build #9891a34] Test results 🔥Test results❌ Tests failed on VSTS: test results 1 tests crashed, 1 tests failed, 265 tests passed. Failures❌ dotnettests tests (tvOS)1 tests failed, 0 tests passed.Failed tests
Html Report (VSDrops) Download ❌ windows tests🔥 Failed catastrophically on VSTS: test results - windows (no summary found). Html Report (VSDrops) Download Successes✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |

Implement the
DeployToDevicetarget as specified in the dotnet run for MAUI spec. This target deploys an already-built app to a device or simulator without rebuilding, enabling thedotnet run --no-buildworkflow.The target:
GetMlaunchArgumentstask to compute install arguments--installdev) and simulators (--installsim)$(Device)property for device selectionComputeAvailableDevicesfor device discoverySdkIsMobileconditionFixes #24382
🤖 Pull request created by Copilot
Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com
Co-authored-by: Rolf Bjarne Kvinge rokvin@microsoft.com
Backport of #25977.