Repository navigation
[release/11.0.2xx] [dotnet watch] Use the selected device's RuntimeIdentifier when evaluating and building projects - #57234
Open
jonathanpeppers wants to merge 1 commit into
Conversation
…dentifier` when evaluating/building projects (#56723) An iOS project can default to a simulator RID, such as `iossimulator-arm64`. If the user selects a physical iPhone in `dotnet watch`, restore and build use `ios-arm64`, but watch keeps the project graph it evaluated before selection. Watch then reads files, such as the Hot Reload WebSocket key, from the simulator's `obj` directory. ### Changes - Reload the project graph with the selected `Device` and `RuntimeIdentifier` when they differ from the evaluated values. Keep the selection for later graph reloads and rebuilds. - Add `DeviceId` to carry the device name and its RID together. - Build projects one at a time when a device RID is set. Solution builds do not accept a global RID (NETSDK1134). - When rebuilding a dependency, pass the device RID only if the dependency is a runnable application. A library builds without a RID, as it does when the app builds it. - Add `_IsRunnableApplication` to `Microsoft.NET.Sdk.targets` and use it in the `IsRidAgnostic` calculation. Watch reads this property instead of duplicating the logic. `IsRidAgnostic` behavior does not change. Backport of #56723. The Device value is not escaped, because the MSBuild property escaping change is not in this branch. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Incorrect runtime-identifier handling causes Hot Reload dependency output paths to diverge from actual builds, while missing framework selection can prevent valid multi-targeted dependencies from rebuilding.
3 open issues
What changed in this PR
Backports the dotnet watch device-RID fix to release/11.0.2xx, aligning project evaluation with the selected device’s build outputs. It intentionally preserves this branch’s existing unescaped device-name handling.
Changes:
- Carries device identity and RID together through graph evaluation, builds, and launches.
- Builds projects individually when a device RID is set and adjusts dependency rebuild handling.
- Adds regression coverage for device selection, output paths, and dependency builds.
| File | Description |
|---|---|
test/dotnet-watch.Tests/HotReload/BuildProjectsTests.cs |
Adds device-RID and dependency rebuild tests. |
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets |
Extracts _IsRunnableApplication for watch to consume. |
src/Dotnet.Watch/Watch/UI/DeviceInfo.cs |
Clarifies selection-display documentation only. |
src/Dotnet.Watch/Watch/Process/ProjectLauncher.cs |
Reads launch device and RID from DeviceId. |
src/Dotnet.Watch/Watch/HotReload/HotReloadDotNetWatcher.cs |
Propagates device properties through evaluation and rebuilds. |
src/Dotnet.Watch/Watch/Context/ProjectOptions.cs |
Replaces separate device fields with DeviceId. |
src/Dotnet.Watch/Watch/Context/DeviceId.cs |
Adds the device identity and optional RID value type. |
src/Dotnet.Watch/Watch/Build/ProjectGraphFactory.cs |
Accepts additional graph evaluation properties. |
src/Dotnet.Watch/Watch/Build/BuildNames.cs |
Adds shared device, RID, and runnable-property names. |
src/Dotnet.Watch/dotnet-watch/Watch/BuildEvaluator.cs |
Reads the device name from the new value type. |
src/Dotnet.Watch/dotnet-watch/CommandLine/CommandLineOptions.cs |
Converts the command-line device into DeviceId. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Backport of #56723 to
release/11.0.2xx.Manual backport, because the automatic backport had conflicts (#56723 (comment)).
Differences from the original PR
release/11.0.2xxdoes not have the change that escapes theDeviceMSBuild property value. This backport passes the device name without escaping, as this branch does now.SingleProject_DeviceIdIsEscapedtest is not included, because it tests that escaping change.Original description
An iOS project can default to a simulator RID, such as
iossimulator-arm64. If the user selects a physical iPhone indotnet watch, restore and build useios-arm64, but watch keeps the project graph it evaluated before selection. Watch then reads files, such as the Hot Reload WebSocket key, from the simulator'sobjdirectory.DeviceandRuntimeIdentifierwhen they differ from the evaluated values. Keep the selection for later graph reloads and rebuilds.DeviceIdto carry the device name and its RID together._IsRunnableApplicationtoMicrosoft.NET.Sdk.targetsand use it in theIsRidAgnosticcalculation.IsRidAgnosticbehavior does not change.