Skip to content

[watch] Fixes command line parsing and TFM selection for FBAs#53698

Merged
tmat merged 5 commits intodotnet:release/10.0.3xxfrom
tmat:FileBasedAppFixes
Apr 15, 2026
Merged

[watch] Fixes command line parsing and TFM selection for FBAs#53698
tmat merged 5 commits intodotnet:release/10.0.3xxfrom
tmat:FileBasedAppFixes

Conversation

@tmat
Copy link
Copy Markdown
Member

@tmat tmat commented Apr 3, 2026

dotnet run uses the first application argument that is not -bl to find file-based app entry point. dotnet watch did not skip the options of run subcommand when parsing the command line. E.g. dotnet run -e X=1 -bl App.cs works but dotnet watch -e X=1 -bl App.cs did not.

Fixes #53598
Fixes #53718

@tmat
Copy link
Copy Markdown
Member Author

tmat commented Apr 3, 2026

@tmat tmat marked this pull request as ready for review April 3, 2026 22:39
@tmat tmat requested a review from a team as a code owner April 3, 2026 22:39
Copilot AI review requested due to automatic review settings April 3, 2026 22:39
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 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 the dotnet run command 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 both dotnet run and dotnet 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.

Comment thread src/Dotnet.Watch/Watch/HotReload/HotReloadDotNetWatcher.cs Outdated
Comment thread src/Dotnet.Watch/Watch/HotReload/HotReloadDotNetWatcher.cs Outdated
Comment thread src/Dotnet.Watch/Watch/Build/ProjectGraphFactory.cs
Comment thread test/dotnet-watch.Tests/HotReload/FileBasedAppTests.cs Outdated
Comment thread src/Microsoft.DotNet.ProjectTools/VirtualProjectBuilder.cs
Comment thread test/dotnet-watch.Tests/HotReload/BuildProjectsTests.cs Outdated
Comment thread src/Dotnet.Watch/dotnet-watch/CommandLine/CommandLineOptions.cs Outdated
@tmat tmat enabled auto-merge (squash) April 6, 2026 20:38
@tmat tmat disabled auto-merge April 6, 2026 21:06
@tmat tmat enabled auto-merge (squash) April 6, 2026 21:07
Comment thread src/Cli/dotnet/Commands/Run/RunCommand.cs
@tmat tmat disabled auto-merge April 7, 2026 20:58
@tmat tmat enabled auto-merge (squash) April 7, 2026 20:59
Copy link
Copy Markdown
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

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.

@tmat
Copy link
Copy Markdown
Member Author

tmat commented Apr 13, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

var seenCommand = false;
var dashDashInserted = false;


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

tiny nit: extra blank line

@tmat
Copy link
Copy Markdown
Member Author

tmat commented Apr 15, 2026

/ba-g Known unrelated test issues:

● All test failures in PR #53698 are already tracked by existing issues:

  1. ✅ C++/CLI tests (8 failures across Microsoft.NET.Build.Tests.dll.4, .dll.16)

Tracked by #53789 (#53789) — C++/CLI tests fail on VS 2026 Helix machines -
MSB8020 v143 platform toolset not found

The VS 2026 scout images only have v180 toolset, but the .vcxproj test assets target v143 (VS 2022). Affects all of:

  • SourceLinkTests.Cpp
  • GivenThatWeWantToBuildACppCliProject.* (all methods)
  • GivenThatWeWantToBuildACppCliProjectWithTransitiveDeps.* (all methods)
  • GivenThatWeWantToPublishACppCliProject.When_referenced_by_csharp_project_it_publishes_and_runs
  1. ✅ It_publishes_the_project_with_a_refs_folder_and_correct_deps_file (net46)

Tracked by #53796 (#53796) —
It_publishes_the_project_with_a_refs_folder_and_correct_deps_file test failure

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

@tmat tmat merged commit 2c7da31 into dotnet:release/10.0.3xx Apr 15, 2026
25 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants