Skip to content

Fix dotnet watch test stuck after build failures in .NET 10#53059

Draft
Copilot wants to merge 6 commits intorelease/10.0.3xxfrom
copilot/fix-continuous-testing-dotnet10
Draft

Fix dotnet watch test stuck after build failures in .NET 10#53059
Copilot wants to merge 6 commits intorelease/10.0.3xxfrom
copilot/fix-continuous-testing-dotnet10

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

In .NET 10, dotnet watch test stops monitoring file changes after a build or compilation error. Users see "Fix the error to continue" but watch ignores subsequent file changes, requiring manual restart.

Root Cause

FileWatcher.WaitForFileChangeAsync() only watched the project file directory non-recursively and only accepted changes to the .csproj file itself. Source file changes went undetected.

Changes

Modified FileWatcher.WaitForFileChangeAsync() to:

  • Watch project directory tree recursively (includeSubdirectories: true)
  • Accept any file change except:
    • bin/ and obj/ directories (build artifacts)
    • Hidden directories (.git, .vs, etc.)
  • Log actual changed file path instead of project file path

Before:

watcher.WatchContainingDirectories([filePath], includeSubdirectories: false);
var fileChange = await watcher.WaitForFileChangeAsync(
    acceptChange: change => change.Path == filePath,
    startedWatching,
    cancellationToken);

After:

watcher.WatchContainingDirectories([filePath], includeSubdirectories: true);
var fileChange = await watcher.WaitForFileChangeAsync(
    acceptChange: change =>
    {
        var relativePath = projectDir != null 
            ? Path.GetRelativePath(projectDir, change.Path)
            : change.Path;
        var pathParts = relativePath.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
        
        return pathParts.Length == 0 || 
               (!pathParts[0].Equals("bin", StringComparison.OrdinalIgnoreCase) &&
                !pathParts[0].Equals("obj", StringComparison.OrdinalIgnoreCase) &&
                !pathParts[0].StartsWith(".", StringComparison.Ordinal));
    },
    startedWatching,
    cancellationToken);

Applies to both dotnet watch test (non-hot-reload) and dotnet watch run (hot-reload) code paths.

Original prompt

This section details on the original issue you should resolve

<issue_title>Continuous testing broken on net10 (dotnet watch test)</issue_title>
<issue_description>### Describe the bug
The command "dotnet watch test" does not work as expected in .net 10. When a test fails or does not compile the command stops monitoring the changes and even though you fix the issue it does not rerun the tests and get stuck with the message "Fix the error to continue or press Ctrl+C to exit.".

To Reproduce

There are two repositories with 12 steps each one, one for the .net9 that works and one for .net10 that does not work:
https://github.com/xcap2000/continuous-testing-net9
https://github.com/xcap2000/continuous-testing-net10

Exceptions (if any)

No exceptions displayed.

Further technical details

I am running in the command line just to isolate the issue, usually I run through tasks in vscode.
The dotnet info will vary if you run the .net 9 or .net 10 because of the global.json defined in each of the projects.
You should be able to run both projects if you have any version of .net9 and any version of .net10 to reproduce the issue.</issue_description>

Comments on the Issue (you are @copilot in this section)

@Youssef1313 @tmat Looks like a regression here.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 5 commits February 17, 2026 19:15
Co-authored-by: tmat <41759+tmat@users.noreply.github.com>
Co-authored-by: tmat <41759+tmat@users.noreply.github.com>
Co-authored-by: tmat <41759+tmat@users.noreply.github.com>
Co-authored-by: tmat <41759+tmat@users.noreply.github.com>
Co-authored-by: tmat <41759+tmat@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix continuous testing issue on .net 10 with dotnet watch test Fix dotnet watch test stuck after build failures in .NET 10 Feb 17, 2026
Copilot AI requested a review from tmat February 17, 2026 19:32
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.

2 participants