Skip to content

Commit 006ecd7

Browse files
authored
Enable GitHub Codespace development (loic-sharma#693)
Enables basic GitHub Codespace support by adding a dev container image. Known problems: * Broken links - The [Forwarded Headers Middleware](https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer?view=aspnetcore-5.0#forwarded-headers) does not seem to be working as expected. For example: * Upload failures - Upload fails with `error: Response status code does not indicate success: 413 (Request Entity Too Large).`. I was able to work around this by enabling upstreaming to nuget.org and download artifacts.
1 parent 8474f25 commit 006ecd7

File tree

4 files changed

+82
-1
lines changed

4 files changed

+82
-1
lines changed

.devcontainer/Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.177.0/containers/dotnet/.devcontainer/base.Dockerfile
3+
4+
# [Choice] .NET version: 5.0, 3.1, 2.1
5+
ARG VARIANT=3.1
6+
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT}

.devcontainer/devcontainer.json

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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.177.0/containers/dotnet
3+
{
4+
"name": "C# (.NET)",
5+
"runArgs": ["--init"],
6+
"build": {
7+
"dockerfile": "Dockerfile",
8+
"args": {
9+
// Update 'VARIANT' to pick a .NET Core version: 2.1, 3.1, 5.0
10+
"VARIANT": "3.1",
11+
// Options
12+
"NODE_VERSION": "lts/*",
13+
"INSTALL_AZURE_CLI": "false"
14+
}
15+
},
16+
17+
// Set *default* container specific settings.json values on container create.
18+
"settings": {},
19+
20+
// Add the IDs of extensions you want installed when the container is created.
21+
"extensions": [
22+
"ms-dotnettools.csharp"
23+
],
24+
25+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
26+
// "forwardPorts": [5000, 5001],
27+
28+
// [Optional] To reuse of your local HTTPS dev cert:
29+
//
30+
// 1. Export it locally using this command:
31+
// * Windows PowerShell:
32+
// dotnet dev-certs https --trust; dotnet dev-certs https -ep "$env:USERPROFILE/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere"
33+
// * macOS/Linux terminal:
34+
// dotnet dev-certs https --trust; dotnet dev-certs https -ep "${HOME}/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere"
35+
//
36+
// 2. Uncomment these 'remoteEnv' lines:
37+
// "remoteEnv": {
38+
// "ASPNETCORE_Kestrel__Certificates__Default__Password": "SecurePwdGoesHere",
39+
// "ASPNETCORE_Kestrel__Certificates__Default__Path": "/home/vscode/.aspnet/https/aspnetapp.pfx",
40+
// },
41+
//
42+
// 3. Do one of the following depending on your scenario:
43+
// * When using GitHub Codespaces and/or Remote - Containers:
44+
// 1. Start the container
45+
// 2. Drag ~/.aspnet/https/aspnetapp.pfx into the root of the file explorer
46+
// 3. Open a terminal in VS Code and run "mkdir -p /home/vscode/.aspnet/https && mv aspnetapp.pfx /home/vscode/.aspnet/https"
47+
//
48+
// * If only using Remote - Containers with a local container, uncomment this line instead:
49+
// "mounts": [ "source=${env:HOME}${env:USERPROFILE}/.aspnet/https,target=/home/vscode/.aspnet/https,type=bind" ],
50+
51+
// Use 'postCreateCommand' to run commands after the container is created.
52+
// "postCreateCommand": "dotnet restore",
53+
54+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
55+
"remoteUser": "vscode"
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
# See: https://github.com/dotnet/aspnetcore/blob/4b4265972d1155e415633a4a177f159b940cf3bb/.devcontainer/scripts/container-creation.sh
4+
5+
set -e
6+
7+
# Install SDK and tool dependencies before container starts
8+
# Also run the full restore on the repo so that go-to definition
9+
# and other language features will be available in C# files
10+
dotnet restore
11+
12+
# Add .NET Dev Certs to environment to facilitate debugging.
13+
# Do **NOT** do this in a public base image as all images inheriting
14+
# from the base image would inherit these dev certs as well.
15+
dotnet dev-certs https
16+
17+
# The container creation script is executed in a new Bash instance
18+
# so we exit at the end to avoid the creation process lingering.
19+
exit

.vscode/launch.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"request": "launch",
1111
"preLaunchTask": "build",
1212
// If you have changed target frameworks, make sure to update the program path.
13-
"program": "${workspaceFolder}/src/BaGet/bin/Debug/netcoreapp2.2/BaGet.dll",
13+
"program": "${workspaceFolder}/src/BaGet/bin/Debug/netcoreapp3.1/BaGet.dll",
1414
"args": [],
1515
"cwd": "${workspaceFolder}/src/BaGet",
1616
"stopAtEntry": false,

0 commit comments

Comments
 (0)