Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit ca17a38

Browse files
authored
Add Dotnet CLI devcontainer feature (#1210)
1 parent 25c5d18 commit ca17a38

File tree

8 files changed

+512
-3
lines changed

8 files changed

+512
-3
lines changed

script-library/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Some scripts have special installation instructions (like `desktop-lite-debian.s
1919
| [Desktop (Lightweight) Install Script](docs/desktop-lite.md) | `desktop-lite-debian.sh` | VS Code and GitHub Codespaces teams|
2020
| [Docker-in-Docker Install Script](docs/docker-in-docker.md) | `docker-in-docker-debian.sh` | VS Code and GitHub Codespaces teams |
2121
| [Docker-from-Docker Install Script](docs/docker.md) | `docker-debian.sh`<br />`docker-redhat.sh` (Community) | VS Code and GitHub Codespaces teams, [@smankoo](https://github.com/smankoo) (`docker-redhat.sh`) |
22+
| [Dotnet Install Script](docs/dotnet.md) | `dotnet-debian.sh` | VS Code and GitHub Codespaces teams |
2223
| [fish Install Script](docs/fish.md) | `fish-debian.sh` (Community) | [@andreiborisov](https://github.com/andreiborisov) |
2324
| [Git Build/Install from Source Script](docs/git-from-src.md) | `git-from-src-debian.sh` | VS Code and GitHub Codespaces teams|
2425
| [Git LFS Install Script](docs/git-lfs.md) | `git-lfs-debian.sh` | VS Code and GitHub Codespaces teams|

script-library/container-features/src/feature-scripts.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ _VSC_INSTALL_HOMEBREW=homebrew-debian.sh
1919
_VSC_INSTALL_RUST="rust-debian.sh /usr/local/cargo /usr/local/rustup automatic true false ${_BUILD_ARG_RUST_VERSION:-latest} ${_BUILD_ARG_RUST_PROFILE:-minimal}"
2020
_VSC_INSTALL_POWERSHELL="powershell-debian.sh ${_BUILD_ARG_POWERSHELL_VERSION:-latest}"
2121
_VSC_INSTALL_DESKTOP_LITE="desktop-lite-debian.sh automatic ${_BUILD_ARG_DESKTOP_LITE_PASSWORD:-vscode} true ${_BUILD_ARG_DESKTOP_LITE_VNCPORT:-5901} ${_BUILD_ARG_DESKTOP_LITE_WEBPORT:-6080}"
22+
_VSC_INSTALL_DOTNET="dotnet-debian.sh ${_BUILD_ARG_DOTNET_VERSION:-latest} ${_BUILD_ARG_DOTNET_RUNTIMEONLY:-false} automatic true /usr/local/dotnet dotnet"

script-library/container-features/src/features.json

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,57 @@
10731073
"puppet",
10741074
"chef"
10751075
]
1076+
},
1077+
{
1078+
"id": "dotnet",
1079+
"name": "Dotnet CLI",
1080+
"documentationURL": "https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/dotnet.md",
1081+
"options": {
1082+
"version": {
1083+
"type": "string",
1084+
"proposals": ["latest","6.0","5.0","3.1"],
1085+
"default": "latest",
1086+
"description": "Select or enter a dotnet CLI version. (Available versions may vary by Linux distribution.)"
1087+
},
1088+
"runtimeOnly": {
1089+
"type":"boolean",
1090+
"default": false,
1091+
"description": "Install just the dotnet runtime if true, and sdk if false."
1092+
}
1093+
},
1094+
"buildArg": "_VSC_INSTALL_DOTNET",
1095+
"containerEnv": {
1096+
"DOTNET_ROOT": "/usr/local/dotnet",
1097+
"PATH": "${PATH}:${DOTNET_ROOT}"
1098+
},
1099+
"extensions": [
1100+
"ms-dotnettools.csharp"
1101+
],
1102+
"include": [
1103+
"cpp",
1104+
"kubernetes-helm",
1105+
"kubernetes-helm-minikube",
1106+
"docker-from-docker",
1107+
"docker-in-docker",
1108+
"powershell",
1109+
"java",
1110+
"go",
1111+
"php",
1112+
"ruby",
1113+
"rust",
1114+
"typescript-node",
1115+
"javascript-node",
1116+
"python-3",
1117+
"python-3-anaconda",
1118+
"python-3-miniconda",
1119+
"ubuntu",
1120+
"debian",
1121+
"javascript-node-mongo",
1122+
"javascript-node-postgres",
1123+
"php-mariadb",
1124+
"ruby-rails-postgres",
1125+
"python-3-postgres"
1126+
]
10761127
}
10771128
]
10781129
}
1079-

script-library/container-features/test-features.env

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@ _BUILD_ARG_GRADLE_VERSION=latest
4040
_VSC_INSTALL_MAVEN=true
4141
_BUILD_ARG_MAVEN_VERSION=latest
4242
_VSC_INSTALL_RUBY=true
43-
_BUILD_ARG_RUBY_VERSION=latest
43+
_BUILD_ARG_RUBY_VERSION=3.0.3
4444
_VSC_INSTALL_RUST=true
4545
_BUILD_ARG_RUST_VERSION=latest
4646
_BUILD_ARG_RUST_PROFILE=minimal
4747
_VSC_INSTALL_POWERSHELL=true
4848
_BUILD_ARG_POWERSHELL_VERSION=latest
4949
_VSC_INSTALL_DESKTOP_LITE=true
50+
_VSC_INSTALL_DOTNET=true
51+
_BUILD_ARG_DOTNET_VERSION=latest
52+
_BUILD_ARG_DOTNET_RUNTIMEONLY=false

script-library/docs/dotnet.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Dotnet CLI Install Script
2+
3+
*Installs the .NET CLI. Provides option of installing sdk or runtime, and option of versions to install. Uses latest version of .NET sdk as defaults to install.*
4+
5+
**Script status**: Stable
6+
7+
**OS support**: Debian 9+, Ubuntu 18.04+, and downstream distros.
8+
9+
**Maintainer:** The VS Code and GitHub Codespaces teams
10+
11+
## Syntax
12+
13+
```text
14+
./dotnet-debian.sh [.NET version] [.NET runtime only] [non-root user] [add TARGET_DOTNET_ROOT to rc files flag] [.NET root] [access group name]
15+
```
16+
17+
Or as a feature:
18+
19+
```json
20+
"features": {
21+
"dotnet": {
22+
"version": "latest",
23+
"runtimeOnly": false
24+
}
25+
}
26+
```
27+
28+
|Argument|Feature option|Default|Description|
29+
|--------|--------------|-------|-----------|
30+
|DOTNET_VERSION| `version` | `latest`| Version of .NET to install. Use `latest` to install the latest released version. |
31+
|DOTNET_RUNTIME_ONLY| `runtimeOnly` | `false` | Install just the .NET runtime if true, and sdk if false. |
32+
|Non-root user| | `automatic`| Specifies a user in the container other than root. A value of `automatic` will cause the script to check for a user called `vscode`, then `node`, `codespace`, and finally a user with a UID of `1000` before falling back to `root`. |
33+
| Add to rc files flag | | `true` | A `true`/`false` flag that indicates whether the `PATH` should be updated and `TARGET_INSTALL_PATH` set via `/etc/bash.bashrc` and `/etc/zsh/zshrc`. |
34+
|Target installation root| | `/usr/local/dotnet`| Location to install .NET. |
35+
|.NET access group| |`dotnet`| Specifies the name of the group that will own the .NET installation. The installing user will be added to that group automatically.|
36+
37+
## Supported Versions
38+
39+
The `dotnet-debian.sh` script supports the following `DOTNET_VERSION` input formats:
40+
41+
- **latest**: if given the keyword "latest", it will attempt to retrieve the latest .NET version.
42+
- **MAJOR**: if given a MAJOR version, it will attempt to retrieve the latest matching MAJOR.minor.patch version.
43+
- **MAJOR.minor**: if given a MAJOR.minor version, it will attempt to retrieve the latest matching MAJOR.minor.patch version.
44+
- **MAJOR.minor.patch**: if given a MAJOR.minor.patch version, it will attempt to retrieve the exact match.
45+
46+
## Usage
47+
48+
### Feature use
49+
50+
To install these capabilities in your primary dev container, reference it in `devcontainer.json` as follows:
51+
52+
```json
53+
"features": {
54+
"dotnet": {
55+
"version": "latest",
56+
"runtimeOnly": false
57+
}
58+
}
59+
```
60+
61+
If you have already built your development container, run the **Rebuild Container** command from the command palette (<kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> or <kbd>F1</kbd>) to pick up the change.
62+
63+
### Script use
64+
65+
1. Add [`dotnet-debian.sh`](../dotnet-debian.sh) to `.devcontainer/library-scripts`
66+
67+
2. Add the following to your `.devcontainer/Dockerfile`:
68+
69+
```Dockerfile
70+
ENV DOTNET_ROOT="/usr/local/dotnet"
71+
ENV PATH="${PATH}:${DOTNET_ROOT}"
72+
COPY library-scripts/dotnet-debian.sh /tmp/library-scripts/
73+
RUN apt-get update && bash /tmp/library-scripts/dotnet-debian.sh
74+
```
75+
76+
That's it!

0 commit comments

Comments
 (0)