guitarrapc / csharp-lab

C# lab

Home Page:https://hub.docker.com/r/guitarrapc/csharp-lab

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Benchmarker Build Docker Build Dotnet Lint Dotnet

Docker Pulls

csharp-lab

To execute Csharp-lab.sln, you need to install following tools.

  • Install .NET8 SDK.
  • Install wasm-tools-net

Container Debugging

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.

image

Select Connection type: to Docker (Linux Container).

image

Select Find, Docker CLI host is Local Machine. Now your docker container is listed.

image

Select container and OK, then Attach.

image

Select Debug these code types to Managed (.NET Core for Unix), then OK.

image

image

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.

image image

Set debugger point and open http://localhost:8080/counter, click Increment button. Debugger stops at your point.

image image

Attach Visual Studio 2022 to Linux Kubernetes Pod

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

About

C# lab

https://hub.docker.com/r/guitarrapc/csharp-lab

License:MIT License


Languages

Language:C# 79.2%Language:HTML 9.5%Language:CSS 7.3%Language:Dockerfile 3.4%Language:JavaScript 0.6%