Skip to content

'dotnet watch' crashes while being modified by CoPilot #55335

Description

@rogihee

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.<<WatchAsync>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

IDE version

No response

Other details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    untriagedRequest triage from a team member

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions