Skip to content

Commit 96c1eea

Browse files
Use dotnet-install.sh in .NET feature (#628)
* Use dotnet-install.sh in .NET feature * Use latest.version files * Cleanup runtime args * Use latest.version files in tests as well * Improve tests, remove code duplication * Add stderr helper * Validate version inputs * Use suggested description Co-authored-by: Samruddhi Khandale <[email protected]> * Shorter version description Co-authored-by: Samruddhi Khandale <[email protected]> * Shorter version description Co-authored-by: Samruddhi Khandale <[email protected]> * Clean up apt lists * Verify 7.0 is latest * Fix PATH, add test for .NET global tools * Include a copy of dotnet-install.sh in the Feature * Configure useful env variables * Use stringly typed booleans * Keep imperative writing style in option hints * Update maintainers Co-authored-by: Samruddhi Khandale <[email protected]> * Move dotnet-install.sh into a vendor directory * Refactor variables * Amend * Amend 2 * Use default options from devcontainer-feature.json * Add back variables * Fix shellchek warning in fetch_latest_sdk_version * Inline install_version function * Fix ShellCheck warnings * Improve CSV parsing * Default to latest when configuring an empty version * Add support for runtime-only configurations * Move 'none' check higher up * Deduplicate helper functions, sort into files * Address the user more directly in NOTES * Remove unnecessary defaults * Replace feature -> Feature Co-authored-by: Samruddhi Khandale <[email protected]> * Add update-dotnet-install-script workflow * Apply suggestions from code review Co-authored-by: Samruddhi Khandale <[email protected]> * Don't skip ci for automated script update --------- Co-authored-by: Samruddhi Khandale <[email protected]>
1 parent 038bed3 commit 96c1eea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2771
-670
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: "Updates vendor 'dotnet-install' script"
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
- cron: '0 0 * * 0' # Runs every Sunday at midnight UTC (adjust as needed)
6+
7+
jobs:
8+
fetch-latest-dotnet-install:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
13+
- name: Run fetch-latest-dotnet-install.sh
14+
run: src/dotnet/scripts/fetch-latest-dotnet-install.sh
15+
16+
- name: Create a PR for dotnet-install.sh
17+
id: push_image_info
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.PAT }}
20+
run: |
21+
set -e
22+
echo "Start."
23+
24+
# Configure git and Push updates
25+
git config --global user.email [email protected]
26+
git config --global user.name github-actions
27+
git config pull.rebase false
28+
29+
branch=automated-script-update-$GITHUB_RUN_ID
30+
git checkout -b $branch
31+
message='[Updates] Automated vendor 'dotnet-install' script'
32+
33+
# Add / update and commit
34+
git add src/dotnet/scripts/vendor/dotnet-install.sh
35+
git commit -m 'Automated dotnet-install script update' || export NO_UPDATES=true
36+
37+
# Push
38+
if [ "$NO_UPDATES" != "true" ] ; then
39+
git push origin "$branch"
40+
gh api \
41+
--method POST \
42+
-H "Accept: application/vnd.github+json" \
43+
/repos/${GITHUB_REPOSITORY}/pulls \
44+
-f title="$message" \
45+
-f body="$message" \
46+
-f head="$branch" \
47+
-f base="$GITHUB_REF_NAME"
48+
fi

src/dotnet/NOTES.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,71 @@
1+
## Configuration examples
12

3+
Installing only the latest .NET SDK version (the default).
4+
5+
``` json
6+
{
7+
"features": {
8+
"ghcr.io/devcontainers/features/dotnet:2": "latest" // or "" or {}
9+
}
10+
```
11+
12+
Installing an additional SDK version. Multiple versions can be specified as comma-separated values.
13+
14+
``` json
15+
{
16+
"features": {
17+
"ghcr.io/devcontainers/features/dotnet:2": {
18+
"additionalVersions": "lts"
19+
}
20+
}
21+
```
22+
23+
Installing specific SDK versions.
24+
25+
``` json
26+
{
27+
"features": {
28+
"ghcr.io/devcontainers/features/dotnet:2": {
29+
"version": "6.0",
30+
"additionalVersions": "7.0, 8.0"
31+
}
32+
}
33+
```
34+
35+
Installing a specific SDK feature band.
36+
37+
``` json
38+
{
39+
"features": {
40+
"ghcr.io/devcontainers/features/dotnet:2": {
41+
"version": "6.0.4xx",
42+
}
43+
}
44+
```
45+
46+
Installing a specific SDK patch version.
47+
48+
``` json
49+
{
50+
"features": {
51+
"ghcr.io/devcontainers/features/dotnet:2": {
52+
"version": "6.0.412",
53+
}
54+
}
55+
```
56+
57+
Installing only the .NET Runtime or the ASP.NET Core Runtime. (The SDK includes all runtimes so this configuration is only useful if you need to run .NET apps without building them from source.)
58+
59+
``` json
60+
{
61+
"features": {
62+
"ghcr.io/devcontainers/features/dotnet:2": {
63+
"version": "none",
64+
"dotnetRuntimeVersions": "latest, lts",
65+
"aspnetCoreRuntimeVersions": "latest, lts",
66+
}
67+
}
68+
```
269

370
## OS Support
471

src/dotnet/devcontainer-feature.json

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,44 @@
11
{
22
"id": "dotnet",
3-
"version": "1.1.4",
3+
"version": "2.0.0",
44
"name": "Dotnet CLI",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/dotnet",
6-
"description": "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.",
6+
"description": "This Feature installs the latest .NET SDK, which includes the .NET CLI and the shared runtime. Options are provided to choose a different version or additional versions.",
77
"options": {
88
"version": {
99
"type": "string",
1010
"proposals": [
1111
"latest",
12-
"7",
13-
"6",
14-
"3.1"
12+
"lts",
13+
"none",
14+
"8.0",
15+
"7.0",
16+
"6.0"
1517
],
1618
"default": "latest",
17-
"description": "Select or enter a dotnet CLI version. (Available versions may vary by Linux distribution.)"
19+
"description": "Select or enter a .NET SDK version. Use 'latest' for the latest version, 'lts' for the latest LTS version, 'X.Y' or 'X.Y.Z' for a specific version."
1820
},
19-
"runtimeOnly": {
20-
"type": "boolean",
21-
"default": false,
22-
"description": "Install just the dotnet runtime if true, and sdk if false."
21+
"additionalVersions": {
22+
"type": "string",
23+
"default": "",
24+
"description": "Enter additional .NET SDK versions, separated by commas. Use 'latest' for the latest version, 'lts' for the latest LTS version, 'X.Y' or 'X.Y.Z' for a specific version."
25+
},
26+
"dotnetRuntimeVersions": {
27+
"type": "string",
28+
"default": "",
29+
"description": "Enter additional .NET runtime versions, separated by commas. Use 'latest' for the latest version, 'lts' for the latest LTS version, 'X.Y' or 'X.Y.Z' for a specific version."
2330
},
24-
"installUsingApt": {
25-
"type": "boolean",
26-
"default": true,
27-
"description": "If true, it installs using apt instead of the release URL"
31+
"aspNetCoreRuntimeVersions": {
32+
"type": "string",
33+
"default": "",
34+
"description": "Enter additional ASP.NET Core runtime versions, separated by commas. Use 'latest' for the latest version, 'lts' for the latest LTS version, 'X.Y' or 'X.Y.Z' for a specific version."
2835
}
2936
},
3037
"containerEnv": {
31-
"DOTNET_ROOT": "/usr/local/dotnet/current",
32-
"PATH": "/usr/local/dotnet/current:${PATH}"
38+
"DOTNET_ROOT": "/usr/share/dotnet",
39+
"PATH": "$PATH:$DOTNET_ROOT:~/.dotnet/tools",
40+
"DOTNET_RUNNING_IN_CONTAINER": "true",
41+
"DOTNET_USE_POLLING_FILE_WATCHER": "true"
3342
},
3443
"customizations": {
3544
"vscode": {

0 commit comments

Comments
 (0)