To execute Csharp-lab.sln, you need to install following tools.
- Install .NET8 SDK.
- Install wasm-tools-net
You can attch Visual Studio 2022 to Linux Docker Container, then debug your application. Let's run Docker.
$ docker build -t blazorserverapp:dev -f src/Blazor/BlazorServerApp/Dockerfile .
$ docker run -p 8080:80 blazorserverapp:dev
warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
Storing keys in a directory '/root/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {98540753-27a5-40cd-8c8c-1a36659ae48f} may be persisted to storage in unencrypted form.
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://[::]:80
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /app/
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d1059e5349f3 blazorserverapp:dev "dotnet BlazorServer…" 4 seconds ago Up 3 seconds 0.0.0.0:8080->80/tcp jolly_kare
Open Visual Studio, Goto Debug > Attach to process
.
Select Connection type:
to Docker (Linux Container)
.
Select Find
, Docker CLI host is Local Machine
. Now your docker container is listed.
Select container and OK
, then Attach
.
Select Debug these code types
to Managed (.NET Core for Unix)
, then OK
.
Because Linux Docker source is differ from Windows source, you need to allow debugging source from different location.
set Debugg Point
and open Settings
, enable Allow the source files to be different from origina
.
Set debugger point and open http://localhost:8080/counter
, click Increment
button. Debugger stops at your point.
https://learn.microsoft.com/en-us/visualstudio/bridge/bridge-to-kubernetes-vs & https://marketplace.visualstudio.com/items?itemName=ms-azuretools.mindaro2022
note: https://itnext.io/how-to-debug-asp-net-core-in-kubernetes-from-visual-studio-2019-1e9d16099d99