'dotnet watch' crashes while being modified by CoPilot
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
### Describe the bug
While prompting in CoPilot Opus prompt in Rider in parallel with running in dotnet watch, it crashed in watching file content:
```
❌ An unexpected error occurred: System.InvalidOperationException: Unexpected true - file HotReloadMSBuildWorkspace.cs line 158
at Microsoft.CodeAnalysis.Contract.Fail(String message, Int32 lineNumber, String filePath)
at Microsoft.CodeAnalysis.ExternalAccess.HotReload.Api.HotReloadMSBuildWorkspace.UpdateFileContentAsync(IEnumerable`1 changedFiles, CancellationToken cancellationToken)
at Microsoft.DotNet.Watch.CompilationHandler.UpdateFileContentAsync(IReadOnlyList`1 changedFiles, CancellationToken cancellationToken)
at Microsoft.DotNet.Watch.HotReloadDotNetWatcher.<>c__DisplayClass13_3.<g__CaptureChangedFilesSnapshot|8>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.DotNet.Watch.HotReloadDotNetWatcher.WatchAsync(CancellationToken shutdownCancellationToken)
at Microsoft.DotNet.Watch.HotReloadDotNetWatcher.WatchAsync(CancellationToken shutdownCancellationToken)
at Microsoft.DotNet.Watch.Program.RunAsync()
```
The launch profile used is:
```
"Highlight Watch": {
"commandName": "Executable",
"executablePath": "dotnet",
"launchBrowser": true,
"launchUrl": "https://localhost:5001/",
"hotReloadEnabled": false,
"workingDirectory": "$(ProjectDir)",
"hotReloadProfile": "blazorwasm",
"commandLineArgs": "watch run --no-launch-profile",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "https://localhost:5001;http://localhost:5000"
}
},
```
### Steps to reproduce
Run watch while prompting in CoPilot :-)
### Expected behavior
Watch should not crash
### Actual behavior
Watch crashes
### Is this a regression?
_No response_
### Are there any workarounds?
_No response_
### dotnet --info output
```console
```
### IDE version
_No response_
### Other details
_No response_
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the HotReloadMSBuildWorkspace.UpdateFileContentAsync stack frame at HotReloadMSBuildWorkspace.cs line 158 and the dotnet watch path through CompilationHandler and HotReloadDotNetWatcher. Reproduce the crash using the provided launch profile while prompting in Copilot from Rider, and capture the missing dotnet --info details. Done means dotnet watch no longer crashes during this file-change scenario.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 38/100