Developing .NET Inside a devcontainer

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”
]
}
}
}

Dockerfile

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

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

How to fix the problem with IntelliSense

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

Be patient!

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

Enjoy 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *