DEV Community

Theodor Heiselberg
Theodor Heiselberg

Posted on

Developing .NET Inside a devcontainer

I really love devcontainers in VS Code! The whole concept that you can define an entire dev environment using just a json file is quite amazing.

Daily, I'm developing .NET applications using C# and sometimes F#.

Here is how you can get an environment up and running in no time - with IntelliSense working!

devcontainer.json

{
    "name": "f-sharp-playground",
    "build":{
        "dockerfile": "Dockerfile"
    },
    "workspaceMount": "source=${localWorkspaceFolder},target=/workspaces,type=bind",
    "workspaceFolder": "/workspaces",
    "customizations": {
        "vscode": {
            "extensions": [
                "ms-dotnettools.csharp",
                "ms-dotnettools.csdevkit",
                "ms-dotnettools.dotnet-interactive-vscode",
                "jebbs.plantuml",
                "Ionide.Ionide-fsharp",
                "ms-dotnettools.vscode-dotnet-runtime"
            ]
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Dockerfile

FROM mcr.microsoft.com/dotnet/sdk:8.0

# E.g. add dotnet tools here:
# RUN dotnet tool install --global dotnet-format

Enter fullscreen mode Exit fullscreen mode

How to fix the problem with IntelliSense

If you didn't add workspaceMount and workspaceFolder you can find the course of IntelliSenses crash here:

Image description

Be patient!

Every time the container rebuilds it takes most of 30 sec to install everything.

Enjoy :)

Top comments (0)