|
| 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