Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit 5fb2c88

Browse files
committed
Add vscode dev container definition
1 parent 5ef026b commit 5fb2c88

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/dotnet/.devcontainer/base.Dockerfile
2+
3+
# [Choice] .NET version: 6.0, 3.1, 6.0-bullseye, 3.1-bullseye, 6.0-focal, 3.1-focal
4+
ARG VARIANT="6.0-bullseye-slim"
5+
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT}
6+
7+
# [Choice] Node.js version: none, lts/*, 18, 16, 14
8+
ARG NODE_VERSION="none"
9+
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
10+
11+
# [Optional] Uncomment this section to install additional OS packages.
12+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
13+
# && apt-get -y install --no-install-recommends <your-package-list-here>
14+
15+
# [Optional] Uncomment this line to install global node packages.
16+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
17+
18+
ARG USERNAME="vscode"
19+
20+
RUN mkdir -p /home/${USERNAME}/.nuget/packages \
21+
&& chown -R ${USERNAME} /home/${USERNAME}/.nuget \
22+
# Persist command history
23+
&& SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \
24+
&& mkdir /commandhistory \
25+
&& touch /commandhistory/.bash_history \
26+
&& chown -R ${USERNAME} /commandhistory \
27+
&& echo "$SNIPPET" >> "/home/${USERNAME}/.bashrc"
28+
29+
USER ${USERNAME}
30+
# Disable github status checks before each command (slows down terminal for large repositories)
31+
RUN git config --global codespaces-theme.hide-status 1

.devcontainer/devcontainer.json

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/dotnet
3+
{
4+
"name": "C# (.NET)",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"args": {
8+
// Update 'VARIANT' to pick a .NET Core version: 3.1, 6.0
9+
// Append -bullseye or -focal to pin to an OS version.
10+
"VARIANT": "6.0-bullseye",
11+
// Options
12+
"NODE_VERSION": "none"
13+
}
14+
},
15+
16+
// Configure tool-specific properties.
17+
"customizations": {
18+
// Configure properties specific to VS Code.
19+
"vscode": {
20+
// Add the IDs of extensions you want installed when the container is created.
21+
"extensions": [
22+
"ms-dotnettools.csharp",
23+
"EditorConfig.EditorConfig",
24+
"ms-azuretools.vscode-docker"
25+
]
26+
}
27+
},
28+
29+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
30+
// "forwardPorts": [5000, 5001],
31+
32+
// [Optional] To reuse of your local HTTPS dev cert:
33+
//
34+
// 1. Export it locally using this command:
35+
// * Windows PowerShell:
36+
// dotnet dev-certs https --trust; dotnet dev-certs https -ep "$env:USERPROFILE/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere"
37+
// * macOS/Linux terminal:
38+
// dotnet dev-certs https --trust; dotnet dev-certs https -ep "${HOME}/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere"
39+
//
40+
// 2. Uncomment these 'remoteEnv' lines:
41+
// "remoteEnv": {
42+
// "ASPNETCORE_Kestrel__Certificates__Default__Password": "SecurePwdGoesHere",
43+
// "ASPNETCORE_Kestrel__Certificates__Default__Path": "/home/vscode/.aspnet/https/aspnetapp.pfx",
44+
// },
45+
//
46+
// 3. Do one of the following depending on your scenario:
47+
// * When using GitHub Codespaces and/or Remote - Containers:
48+
// 1. Start the container
49+
// 2. Drag ~/.aspnet/https/aspnetapp.pfx into the root of the file explorer
50+
// 3. Open a terminal in VS Code and run "mkdir -p /home/vscode/.aspnet/https && mv aspnetapp.pfx /home/vscode/.aspnet/https"
51+
//
52+
// * If only using Remote - Containers with a local container, uncomment this line instead:
53+
// "mounts": [ "source=${env:HOME}${env:USERPROFILE}/.aspnet/https,target=/home/vscode/.aspnet/https,type=bind" ],
54+
55+
// Use 'postCreateCommand' to run commands after the container is created.
56+
// "postCreateCommand": "dotnet restore",
57+
58+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
59+
"remoteUser": "vscode",
60+
"features": {
61+
"git": "os-provided"
62+
},
63+
"mounts": [
64+
// Add a volume for nuget packages. Speeds up subsequent builds
65+
"source=msgraph-cli-nuget,target=/home/vscode/.nuget/packages,type=volume",
66+
"source=msgraph-cli-bashhistory,target=/commandhistory,type=volume"
67+
]
68+
}

0 commit comments

Comments
 (0)