[watch] Fixes command line parsing and TFM selection for FBAs#53698
[watch] Fixes command line parsing and TFM selection for FBAs#53698tmat merged 5 commits intodotnet:release/10.0.3xxfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes dotnet watch file-based app (FBA) command-line parsing so the correct entry point is discovered even when dotnet run options (like -e and -bl) are present, and adds/improves target framework selection behavior for FBAs (including multi-targeting prompts).
Changes:
- Parse
dotnet watch“run” arguments using thedotnet runcommand definition so run-subcommand options don’t confuse entry point detection. - Add shared directive parsing helper (
VirtualProjectBuilder.GetPropertyFromSourceFile) and use it for FBA TFM selection in bothdotnet runanddotnet watch. - Add/adjust tests covering binlog stripping, FBA include directive/hotreload, and FBA TFM selection.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/Microsoft.NET.TestFramework/TestAssetsManager.cs | Adds helper to create an empty test asset directory for new tests. |
| test/dotnet-watch.Tests/HotReload/FileBasedAppTests.cs | New hot reload tests for FBA include directives and TFM selection prompting. |
| test/dotnet-watch.Tests/HotReload/CompilationHandlerTests.cs | Updates ProjectGraphFactory usage after signature change. |
| test/dotnet-watch.Tests/HotReload/BuildProjectsTests.cs | Adds unit tests covering FBA framework selection behavior during builds. |
| test/dotnet-watch.Tests/CommandLine/ProgramTests.GetProjectOptions.cs | Adds regression coverage for -bl/-e not breaking FBA entry point detection. |
| test/dotnet-watch.Tests/CommandLine/CommandLineOptionsTests.cs | Updates tests for Command type change and binlog stripping behavior. |
| test/dotnet-watch.Tests/Build/ProjectGraphFactoryTests.cs | Updates tests to new TryLoadProjectGraph signature. |
| src/Microsoft.DotNet.ProjectTools/VirtualProjectBuilder.cs | Introduces a shared helper to read #:property values from source directives. |
| src/Microsoft.DotNet.ProjectTools/PublicAPI.Unshipped.txt | Records the newly added public API surface. |
| src/Dotnet.Watch/Watch/HotReload/HotReloadDotNetWatcher.cs | Implements FBA directive-based TFM selection and threads virtual-project TFM into graph loading. |
| src/Dotnet.Watch/Watch/Build/ProjectGraphFactory.cs | Moves virtual-project TFM from constructor to per-call parameter. |
| src/Dotnet.Watch/dotnet-watch/Watch/MsBuildFileSetFactory.cs | Updates graph loading call to pass virtual-project TFM. |
| src/Dotnet.Watch/dotnet-watch/Program.cs | Fixes FBA entry point detection by parsing args with RunCommandDefinition. |
| src/Dotnet.Watch/dotnet-watch/CommandLine/CommandLineOptions.cs | Changes Command to System.CommandLine.Command and adds binlog-stripped args list. |
| src/Cli/dotnet/Commands/Run/RunCommand.cs | Uses the shared directive helper for multi-target FBA framework selection. |
jonathanpeppers
left a comment
There was a problem hiding this comment.
The changes here make sense to me, but they would mostly apply to console apps with TargetFrameworks set -- seems like a rare use-case.
I don't see how we could make file-based .NET MAUI apps work anytime soon -- both iOS and Android require multiple files (app icons, manifests), we'd have to generate "default" ones in obj -- no plans to do that at the moment.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| var seenCommand = false; | ||
| var dashDashInserted = false; | ||
|
|
||
|
|
There was a problem hiding this comment.
tiny nit: extra blank line
|
/ba-g Known unrelated test issues: ● All test failures in PR #53698 are already tracked by existing issues:
Tracked by #53789 (#53789) — C++/CLI tests fail on VS 2026 Helix machines - The VS 2026 scout images only have v180 toolset, but the .vcxproj test assets target v143 (VS 2022). Affects all of:
Tracked by #53796 (#53796) — The mscorlib.dll vs .NETFramework/v4.6/m… string mismatch in the deps file. Consistently fails in CI. All failures in PR #53698 are known issues — none are new |
dotnet runuses the first application argument that is not-blto find file-based app entry point.dotnet watchdid not skip the options of run subcommand when parsing the command line. E.g.dotnet run -e X=1 -bl App.csworks butdotnet watch -e X=1 -bl App.csdid not.Fixes #53598
Fixes #53718