microsoft / microsoft/aspire

Debugging a Blazor WASM or JS Frontend doesn't hit breakpoints in IDE

Open
#5,819 45 comments 14 reactions 2 assignees Assigned to @LittleLittleCloud View on GitHub
area-tooling blazor-wasm
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

For reference, I did do a search on `blazor wasm` on **all** issues and found these related ones

1. #1793
But this one seems to be about debugging in the browser, whereas I'm looking for debugging in my IDE.
2. #1418
Seems to be about exactly what I'd like to do but is closed and I can't provide any input there.

The issue at hand is as follows

1. Having a project `Microsoft.NET.Sdk.BlazorWebAssembly`;
2. Put a breakpoint at some code;
3. When debugging the project directly, a debugger attaches just fine, and breakpoints are hit;
4. When debugging via .NET Aspire, seemingly no debugger attaches and breakpoints are **not** hit.

### Expected Behavior

Start a debug session on a .NET Aspire project and being able to debug Blazor WASM projects, just like any other regular .NET project can be debugged.

### Steps To Reproduce

1. dotnet new aspire
2. dotnet new blazorwasm -o Web
3. dotnet sln add Web
4. dotnet add AppHost.AppHost reference Web
5. Add `_ = builder.AddProject("web");` to `AppHost.AppHost/Program.cs`
6. Add a breakpoint at `Web/Pages/Counter.razor` in the `IncrementCount` method

When starting a debug session directly on the `Web` project, a browser tab will open up. It will initially say that a debugger is being attached and after that, it will actually load. Going to the Counter page and clicking the button will hit the breakpoint.
![image](https://github.com/user-attachments/assets/951cadba-e377-4a43-832c-304e6f291780)
![image](https://github.com/user-attachments/assets/436aca4d-7603-4c79-a6f5-b2087bd68c7d)
![image](https://github.com/user-attachments/assets/a6c58a71-a39b-485d-9e2c-252db32279f0)

When starting a debug session on the `AppHost.AppHost` project, a browser tab will open up. It shows the dashboard and navigating to the `Web` project doesn't show the debugger being attached message and goes straight into the regular loading. Going to the Counter page and clicking the button will **not** hit the breakpoint.
![image](https://github.com/user-attachments/assets/a16247ca-0afa-4591-8296-6627e885d532)
![image](https://github.com/user-attachments/assets/0f81a520-fbd5-40b1-ae9b-108f63d03900)

The very deceiving part is that it does say the debugger is being attached, but in reality, it's not. Here's a screenshot of the scenario with Visual Studio instead. As you can see, then there's no message at all of a debugger being attached. This is also the case for debugging `Web` directly by the way (but then the breakpoints do get hit).
![image](https://github.com/user-attachments/assets/f04a35e9-7fc2-4d68-898c-e59a272187f6)

### Exceptions (if any)

_No response_

### .NET Version info

`dotnet --info`
```
.NET SDK:
Version: 8.0.205
Commit: 3e1383b780
Workload version: 8.0.200-manifests.f51a3a6b

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.205\

.NET workloads installed:
[aspire]
Installation Source: SDK 8.0.200
Manifest Version: 8.2.0/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.0\WorkloadManifest.json
Install Type: Msi

Host:
Version: 8.0.8
Architecture: x64
Commit: 08338fcaa5

.NET SDKs installed:
8.0.108 [C:\Program Files\dotnet\sdk]
8.0.200 [C:\Program Files\dotnet\sdk]
8.0.205 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download
```

### Anything else?

I've tried this with Visual Studio `17.9.7` and Rider `2024.2.5` and they show exactly the same behavior. I am running on Windows `23H2` = `22631.4169`.

`dotnet workload list`
```
Installed Workload Id Manifest Version Installation Source
--------------------------------------------------------------------
aspire 8.2.0/8.0.100 SDK 8.0.200
```

Please note that the following packages were used
```

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.