CSharp VSCode

From bibbleWiki
Jump to navigation Jump to search

Introduction

This page is to capture the issues using c# with VS Code

SDK Error

So the main purpose of this page

Don't like solving problems twice but though MS would have solved it for me. So here we go. So copilot was has to solve this

sudo ln -s /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet
export PATH=$PATH:/snap/bin

Obviously you need to update the .bashrc or what ever appropriately. BUT THIS DID NOT WORK. This subsequently fails with GLIBC_PRIVATE not defined error in dotnet SDK when installed via snap
To solve this I ended up install via apt. This was on Ubuntu 24.04

sudo apt install dotnet-sdk-8.0

Once installed I did have to change by launch file to get debugging to work. This might be cause it was originally wrong but this is a reminder to myself.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Launch (web)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/Catalog.Api/bin/Debug/net8.0/Catalog.Api.dll",
            "args": [],
            "cwd": "${workspaceFolder}",
            "stopAtEntry": false,
            "serverReadyAction": {
                "action": "openExternally",
                "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
            },
            "env": {
                "ASPNETCORE_ENVIRONMENT": "Development"
            },
            "sourceFileMap": {
                "/Views": "${workspaceFolder}/Views"
            }
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach"
        },
        {
            "name": "Docker .NET Launch",
            "type": "docker",
            "request": "launch",
            "preLaunchTask": "docker-run: debug",
            "netCore": {
                "appProject": "${workspaceFolder}/Catalog.Api.csproj"
            }
        }
    ]
}