Skip to content

Commit 2e8ba58

Browse files
Support devcontainer (#3334)
1 parent a99800c commit 2e8ba58

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# See here for image contents: https://github.com/devcontainers/images/blob/main/src/dotnet/.devcontainer/Dockerfile
2+
# Example of using a preview version: mcr.microsoft.com/devcontainers/dotnet:10.0-preview
3+
4+
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:latest
5+
6+
# [Option] Install Node.js
7+
ARG INSTALL_NODE="true"
8+
ARG NODE_VERSION="lts/*"
9+
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi

.devcontainer/devcontainer.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/devcontainers/images/tree/main/src/dotnet
3+
{
4+
"name": "C# (.NET)",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"args": {
8+
// Options
9+
"INSTALL_NODE": "true",
10+
"NODE_VERSION": "lts/*"
11+
}
12+
},
13+
// Add the IDs of extensions you want installed when the container is created.
14+
"customizations": {
15+
"vscode": {
16+
"extensions": [
17+
"ms-dotnettools.csdevkit"
18+
],
19+
"settings": {
20+
"dotnet.defaultSolution": "Microsoft.Identity.Web.sln",
21+
"omnisharp.enableRoslynAnalyzers": true,
22+
"omnisharp.enableEditorConfigSupport": true,
23+
"omnisharp.enableImportCompletion": true
24+
}
25+
}
26+
},
27+
// Use 'postCreateCommand' to run commands after the container is created.
28+
"onCreateCommand": "bash -i ${containerWorkspaceFolder}/.devcontainer/scripts/container-creation.sh",
29+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
30+
"remoteUser": "vscode",
31+
"hostRequirements": {
32+
"cpus": 4
33+
},
34+
"features": {
35+
"ghcr.io/devcontainers/features/azure-cli:1": {},
36+
"ghcr.io/devcontainers/features/dotnet:2": {
37+
"workloads": "wasm-tools"
38+
}
39+
}
40+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# Add .NET Dev Certs to environment to facilitate debugging.
6+
# Do **NOT** do this in a public base image as all images inheriting
7+
# from the base image would inherit these dev certs as well.
8+
dotnet dev-certs https
9+
10+
# The container creation script is executed in a new Bash instance
11+
# so we exit at the end to avoid the creation process lingering.
12+
exit

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"files.trimTrailingWhitespace": true,
3+
"files.associations": {
4+
"*.*proj": "xml",
5+
"*.props": "xml",
6+
"*.targets": "xml",
7+
"*.tasks": "xml"
8+
}
9+
}

0 commit comments

Comments
 (0)