diff --git a/.devcontainer/libraries/Dockerfile b/.devcontainer/libraries/Dockerfile new file mode 100644 index 00000000000000..ff924ca7466f9b --- /dev/null +++ b/.devcontainer/libraries/Dockerfile @@ -0,0 +1,29 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.192.0/containers/dotnet/.devcontainer/base.Dockerfile +# For details on dotnet specific container, see: https://github.com/microsoft/vscode-dev-containers/tree/main/containers/dotnet + +# [Choice] .NET version: 6.0, 3.1 +ARG VARIANT="6.0-focal" +FROM mcr.microsoft.com/devcontainers/dotnet:0-${VARIANT} + +# Set up machine requirements to build the repo and the gh CLI +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends \ + cmake \ + llvm-10 \ + clang-10 \ + build-essential \ + python \ + curl \ + git \ + lldb-6.0 \ + liblldb-6.0-dev \ + libunwind8 \ + libunwind8-dev \ + gettext \ + libicu-dev \ + liblttng-ust-dev \ + libssl-dev \ + libnuma-dev \ + libkrb5-dev \ + zlib1g-dev \ + ninja-build diff --git a/.devcontainer/libraries/devcontainer.json b/.devcontainer/libraries/devcontainer.json new file mode 100644 index 00000000000000..09daf0ecf6c6f8 --- /dev/null +++ b/.devcontainer/libraries/devcontainer.json @@ -0,0 +1,55 @@ +// For format details, see https://aka.ms/devcontainer.json. +{ + "name": "C# (.NET)", + "build": { + "dockerfile": "Dockerfile", + "args": { + // Update 'VARIANT' to pick a .NET Core version: 3.1, 6.0 + // Append -bullseye or -focal to pin to an OS version. + "VARIANT": "6.0-focal" + } + }, + "hostRequirements": { + "cpus": 4, + "memory": "8gb" + }, + + "features": { + "ghcr.io/devcontainers/features/github-cli:1": {} + }, + + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-dotnettools.csharp" + ], + "settings": { + // Loading projects on demand is better for larger codebases + "omnisharp.enableMsBuildLoadProjectsOnDemand": true, + "omnisharp.enableRoslynAnalyzers": true, + "omnisharp.enableEditorConfigSupport": true, + "omnisharp.enableAsyncCompletion": true, + "omnisharp.testRunSettings": "${containerWorkspaceFolder}/artifacts/obj/vscode/.runsettings" + } + } + }, + + // Use 'onCreateCommand' to run pre-build commands inside the codespace + "onCreateCommand": "${containerWorkspaceFolder}/.devcontainer/scripts/onCreateCommand.sh libraries", + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "${containerWorkspaceFolder}/.devcontainer/scripts/postCreateCommand.sh", + + // Add the locally installed dotnet to the path to ensure that it is activated + // This allows developers to just use 'dotnet build' on the command-line, and the local dotnet version will be used. + "remoteEnv": { + "PATH": "${containerWorkspaceFolder}/.dotnet:${containerEnv:PATH}", + "DOTNET_MULTILEVEL_LOOKUP": "0" + }, + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" +} diff --git a/.devcontainer/scripts/onCreateCommand.sh b/.devcontainer/scripts/onCreateCommand.sh index 48850f5f00b719..f84c90b1878bb2 100755 --- a/.devcontainer/scripts/onCreateCommand.sh +++ b/.devcontainer/scripts/onCreateCommand.sh @@ -2,18 +2,26 @@ set -e -# prebuild the repo, so it is ready for development -./build.sh libs+clr -rc Release -# restore libs tests so that the project is ready to be loaded by OmniSharp -./build.sh libs.tests -restore +opt=$1 +case "$opt" in -# prebuild for WASM, so it is ready for wasm development -make -C src/mono/wasm provision-wasm -export EMSDK_PATH=$PWD/src/mono/wasm/emsdk -./build.sh mono+libs -os Browser -c release + libraries) + # prebuild the repo, so it is ready for development + ./build.sh libs+clr -rc Release + # restore libs tests so that the project is ready to be loaded by OmniSharp + ./build.sh libs.tests -restore + ;; -# install dotnet-serve for running wasm samples -./dotnet.sh tool install dotnet-serve --tool-path ./.dotnet-tools-global + wasm) + # prebuild for WASM, so it is ready for wasm development + make -C src/mono/wasm provision-wasm + export EMSDK_PATH=$PWD/src/mono/wasm/emsdk + ./build.sh mono+libs -os Browser -c Release + + # install dotnet-serve for running wasm samples + ./dotnet.sh tool install dotnet-serve --tool-path ./.dotnet-tools-global + ;; +esac # save the commit hash of the currently built assemblies, so developers know which version was built git rev-parse HEAD > ./artifacts/prebuild.sha diff --git a/.devcontainer/Dockerfile b/.devcontainer/wasm/Dockerfile similarity index 64% rename from .devcontainer/Dockerfile rename to .devcontainer/wasm/Dockerfile index 54f5f2ff58bb80..cd29264dbff299 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/wasm/Dockerfile @@ -1,22 +1,32 @@ # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.192.0/containers/dotnet/.devcontainer/base.Dockerfile # For details on dotnet specific container, see: https://github.com/microsoft/vscode-dev-containers/tree/main/containers/dotnet -# [Choice] .NET version: 6.0, 5.0, 3.1, 2.1 +# [Choice] .NET version: 6.0, 3.1 ARG VARIANT="6.0-focal" -FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT} - -# Setup the gh (GitHub) CLI signing key. -RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg && \ - chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg && \ - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null +FROM mcr.microsoft.com/devcontainers/dotnet:0-${VARIANT} # Set up machine requirements to build the repo and the gh CLI RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends cmake llvm-10 clang-10 \ - build-essential python curl git lldb-6.0 liblldb-6.0-dev \ - libunwind8 libunwind8-dev gettext libicu-dev liblttng-ust-dev \ - libssl-dev libnuma-dev libkrb5-dev zlib1g-dev ninja-build \ - gh + && apt-get -y install --no-install-recommends \ + cmake \ + llvm-10 \ + clang-10 \ + build-essential \ + python \ + curl \ + git \ + lldb-6.0 \ + liblldb-6.0-dev \ + libunwind8 \ + libunwind8-dev \ + gettext \ + libicu-dev \ + liblttng-ust-dev \ + libssl-dev \ + libnuma-dev \ + libkrb5-dev \ + zlib1g-dev \ + ninja-build # Install V8 Engine SHELL ["/bin/bash", "-c"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/wasm/devcontainer.json similarity index 55% rename from .devcontainer/devcontainer.json rename to .devcontainer/wasm/devcontainer.json index d7b5a8b0efb57a..44fca5078392db 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/wasm/devcontainer.json @@ -1,31 +1,44 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: -// https://github.com/microsoft/vscode-dev-containers/tree/v0.192.0/containers/dotnet +// For format details, see https://aka.ms/devcontainer.json. { "name": "C# (.NET)", "build": { "dockerfile": "Dockerfile", "args": { - // Update 'VARIANT' to pick a .NET Core version: 2.1, 3.1, 5.0 - "VARIANT": "5.0", + // Update 'VARIANT' to pick a .NET Core version: 3.1, 6.0 + // Append -bullseye or -focal to pin to an OS version. + "VARIANT": "6.0-focal" } }, + "hostRequirements": { + "cpus": 4, + "memory": "8gb" + }, - "settings": { - // Loading projects on demand is better for larger codebases - "omnisharp.enableMsBuildLoadProjectsOnDemand": true, - "omnisharp.enableRoslynAnalyzers": true, - "omnisharp.enableEditorConfigSupport": true, - "omnisharp.enableAsyncCompletion": true, - "omnisharp.testRunSettings": "${containerWorkspaceFolder}/artifacts/obj/vscode/.runsettings" + "features": { + "ghcr.io/devcontainers/features/github-cli:1": {} }, - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "ms-dotnettools.csharp" - ], + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-dotnettools.csharp" + ], + "settings": { + // Loading projects on demand is better for larger codebases + "omnisharp.enableMsBuildLoadProjectsOnDemand": true, + "omnisharp.enableRoslynAnalyzers": true, + "omnisharp.enableEditorConfigSupport": true, + "omnisharp.enableAsyncCompletion": true, + "omnisharp.testRunSettings": "${containerWorkspaceFolder}/artifacts/obj/vscode/.runsettings" + } + } + }, // Use 'onCreateCommand' to run pre-build commands inside the codespace - "onCreateCommand": "${containerWorkspaceFolder}/.devcontainer/scripts/onCreateCommand.sh", + "onCreateCommand": "${containerWorkspaceFolder}/.devcontainer/scripts/onCreateCommand.sh wasm", // Use 'postCreateCommand' to run commands after the container is created. "postCreateCommand": "${containerWorkspaceFolder}/.devcontainer/scripts/postCreateCommand.sh", diff --git a/docs/workflow/Codespaces.md b/docs/workflow/Codespaces.md index 8473f17beb4ffe..edc0959f1cc58c 100644 --- a/docs/workflow/Codespaces.md +++ b/docs/workflow/Codespaces.md @@ -7,9 +7,20 @@ dotnet/runtime runs a nightly GitHub Action to build the latest code in the repo 1. From https://github.com/dotnet/runtime, drop-down the `Code` button and select the `Codespaces` tab. -![New codespace button](https://docs.github.com/assets/images/help/codespaces/new-codespace-button.png) +![New codespace button](https://docs.github.com/assets/cb-138303/images/help/codespaces/new-codespace-button.png) -2. Select the Machine type. For dotnet/runtime, it is recommended to select at least a `4-core` machine. You can also verify that a "Prebuild" is ready. +2. Click the drop-down at the side of the `Create codespace on main` button and select `Configure and create codespace` + +![Configure and create codespace](https://docs.github.com/assets/cb-49317/images/help/codespaces/default-machine-type.png) + +3. Select which Dev container configuration you want to use. + +![Dev container configuration](./codespace-dev-container-configuration.png) + + - For `libraries` work, pick `.devcontainer/libraries/devcontainer.json`. + - For `WASM` work, pick `.devcontainer/wasm/devcontainer.json`. + +4. Select the Machine type. For `dotnet/runtime`, it is recommended to select at least a `4-core` machine. You can also verify that a `Prebuild` is ready. ![Codespace machine size](./codespace-machine-size.png) @@ -20,21 +31,15 @@ dotnet/runtime runs a nightly GitHub Action to build the latest code in the repo The Codespaces configuration is spread across the following places: -1. The [.devcontainer](../../.devcontainer) folder contains: - - `devcontainer.json` file configures the codespace and mostly has VS Code settings - - The Dockerfile used to create the image +1. The [.devcontainer](../../.devcontainer) folder contains folders for each "development scenario": + - `libraries` - Used by developers working in `src/libraries` + - `wasm` - Used by developers working on the browser-wasm workload - The `scripts` folder contains any scripts that are executed during the creation of the codespace. This has the build command that builds the entire repo for prebuilds. -2. The GitHub Action can be configured by following the instructions at https://docs.github.com/codespaces/prebuilding-your-codespaces/configuring-prebuilds. +2. Each development scenario folder contains: + - `devcontainer.json` file configures the codespace and has VS Code / Environment settings + - The Dockerfile used to create the Docker image +3. The GitHub Action can be configured by following the instructions at https://docs.github.com/codespaces/prebuilding-your-codespaces/configuring-prebuilds. To test out changes to the `.devcontainer` files, you can follow the process in [Applying changes to your configuration](https://docs.github.com/codespaces/customizing-your-codespace/configuring-codespaces-for-your-project#applying-changes-to-your-configuration) docs. This allows you to rebuild the Codespace privately before creating a PR. -To test out your `.yml` changes, here is the process: - -**Note**: *Executing these steps will overwrite the current prebuilt container for the entire repo. Afterwards, anyone creating a new codespace will get a prebuilt machine with your test changes until the Action in `main` is executed again.* - -1. Edit and commit the files to a branch. -2. Push that to a branch on dotnet/runtime. Be careful that you aren't pushing to `main` or some other important branch. Prefix your branch name with your GitHub account name, so others know it is a dev branch. ex. `username/FixCodespaces`. -3. In the "Actions" tab at the top of dotnet/runtime: - - Select "Create Codespaces Prebuild" action on the left - - On the right click "Run workflow" and pick your branch - - After it runs, try to create a codespace +To test out your changes you can run the [Codespaces Prebuilds Action](https://github.com/dotnet/runtime/actions/workflows/codespaces/create_codespaces_prebuilds) in your fork against a branch with your changes. \ No newline at end of file diff --git a/docs/workflow/codespace-dev-container-configuration.png b/docs/workflow/codespace-dev-container-configuration.png new file mode 100644 index 00000000000000..0e03dab4b089c5 Binary files /dev/null and b/docs/workflow/codespace-dev-container-configuration.png differ