From 0ff482d02974bd0be0e99184094f5f6da29a5334 Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Mon, 19 Aug 2024 15:43:03 -0700 Subject: [PATCH] Dev Container (#10751) --- .devcontainer/Dockerfile | 19 +++++++++ .devcontainer/devcontainer.json | 60 +++++++++++++++++++++++++++ .vscode/settings.json | 3 +- .vscode/tasks.json | 73 ++++++++++++++++++++++----------- 4 files changed, 130 insertions(+), 25 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000..5fb9d493e7 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,19 @@ +FROM mcr.microsoft.com/dotnet/sdk:8.0 + +ARG DOTNET_SDK_INSTALL_URL=https://dot.net/v1/dotnet-install.sh +# Install the correct Roslyn SDK into the same directory that the base image installs the SDK in. +ENV DOTNET_INSTALL_DIR=/usr/share/dotnet + +# Copy the global.json file so its available in the image before the repo is cloned +COPY global.json /tmp/ + +RUN cd /tmp \ + && curl --location --output dotnet-install.sh "${DOTNET_SDK_INSTALL_URL}" \ + && chmod +x dotnet-install.sh \ + && mkdir -p "${DOTNET_INSTALL_DIR}" \ + && ./dotnet-install.sh --jsonfile "./global.json" --install-dir "${DOTNET_INSTALL_DIR}" \ + && rm dotnet-install.sh + +# Set up machine requirements to build the repo +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends curl git \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..04a9664485 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,60 @@ +// 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.140.1/containers/dotnetcore +{ + "name": "Razor DevContainer", + "build": { + "dockerfile": "Dockerfile", + // Set the context to the workspace folder to allow us to copy files from it. + "context": ".." + }, + "customizations": { + "vscode": { + "settings": { + "files.associations": { + "*.csproj": "msbuild", + "*.fsproj": "msbuild", + "*.globalconfig": "ini", + "*.manifest": "xml", + "*.nuspec": "xml", + "*.pkgdef": "ini", + "*.projitems": "msbuild", + "*.props": "msbuild", + "*.resx": "xml", + "*.rsp": "Powershell", + "*.ruleset": "xml", + "*.settings": "xml", + "*.shproj": "msbuild", + "*.slnf": "json", + "*.targets": "msbuild", + "*.vbproj": "msbuild", + "*.vsixmanifest": "xml", + "*.vstemplate": "xml", + "*.xlf": "xml", + "*.yml": "azure-pipelines" + }, + // ms-dotnettools.csharp settings + "omnisharp.disableMSBuildDiagnosticWarning": true, + "omnisharp.enableEditorConfigSupport": true, + "omnisharp.enableImportCompletion": true, + "omnisharp.useModernNet": true, + "omnisharp.enableAsyncCompletion": true, + // ms-dotnettools.csdevkit settings + "dotnet.defaultSolution": "Razor.sln", + // ms-vscode.powershell settings + "powershell.promptToUpdatePowerShell": false, + "powershell.integratedConsole.showOnStartup": false, + "powershell.startAutomatically": false, + // ms-azure-devops.azure-pipelines settings + }, + "extensions": [ + "ms-dotnettools.csharp", + "ms-dotnettools.csdevkit", + "EditorConfig.EditorConfig", + "ms-vscode.powershell", + "tintoy.msbuild-project-tools", + "ms-azure-devops.azure-pipelines" + ] + } + }, + "postCreateCommand": "${containerWorkspaceFolder}/restore.sh" +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index f9c2ef84cb..b3c579440c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,5 +15,6 @@ }, "dotnet.defaultSolution": "Razor.sln", "omnisharp.defaultLaunchSolution": "Razor.sln", - "files.encoding": "utf8bom" + "files.encoding": "utf8bom", + "dotnet.testWindow.disableBuildOnRefresh": true } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 6cf71f4a89..776a214d8b 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,27 +1,52 @@ { - "version": "2.0.0", - "tasks": [ - { - "label": "ActivateDotnet", - "type": "shell", - "windows": { - "command": "echo", - "args": [ - "Skipping activation on windows" - ] - }, - "linux": { - "command": "source", - "args": [ - "activate.sh" - ], - "options": { - "cwd": "${workspaceFolder}" - }, - "presentation": { - "reveal": "silent" - } - }, + "version": "2.0.0", + "tasks": [ + { + "label": "ActivateDotnet", + "type": "shell", + "windows": { + "command": "echo", + "args": [ + "Skipping activation on windows" + ] + }, + "linux": { + "command": "source", + "args": [ + "activate.sh" + ], + "options": { + "cwd": "${workspaceFolder}" }, - ] + "presentation": { + "reveal": "silent" + } + }, + }, + { + "label": "build.sh", + "command": "./build.sh", + "type": "shell", + "args": [ + ], + "windows": { + "command": "${workspaceFolder}/build.cmd", + }, + "problemMatcher": "$msCompile", + "group": "build" + }, + { + "label": "build Rasor.Slim.slnf", + "command": "dotnet", + "type": "shell", + "args": [ + "build", + "-p:RunAnalyzersDuringBuild=false", + "-p:GenerateFullPaths=true", + "Razor.Slim.slnf" + ], + "problemMatcher": "$msCompile", + "group": "build" + } + ] } \ No newline at end of file