Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dotnet/NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Installing .NET workloads. Multiple workloads can be specified as comma-separate
``` json
"features": {
"ghcr.io/devcontainers/features/dotnet:2": {
"workloads": "aspire, wasm-tools"
"workloads": "wasm-tools"
}
}
```
Expand Down
10 changes: 5 additions & 5 deletions src/dotnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ This Feature installs the latest .NET SDK, which includes the .NET CLI and the s

| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|
| version | 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. | string | latest |
| additionalVersions | 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. | string | - |
| dotnetRuntimeVersions | 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. | string | - |
| aspNetCoreRuntimeVersions | 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. | string | - |
| version | 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, 'X.Y-preview' or 'X.Y-daily' for prereleases. | string | latest |
| additionalVersions | 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, 'X.Y-preview' or 'X.Y-daily' for prereleases. | string | - |
| dotnetRuntimeVersions | 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, 'X.Y-preview' or 'X.Y-daily' for prereleases. | string | - |
| aspNetCoreRuntimeVersions | 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, 'X.Y-preview' or 'X.Y-daily' for prereleases. | string | - |
| workloads | Enter additional .NET SDK workloads, separated by commas. Use 'dotnet workload search' to learn what workloads are available to install. | string | - |

## Customizations
Expand Down Expand Up @@ -95,7 +95,7 @@ Installing .NET workloads. Multiple workloads can be specified as comma-separate
``` json
"features": {
"ghcr.io/devcontainers/features/dotnet:2": {
"workloads": "aspire, wasm-tools"
"workloads": "wasm-tools"
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion src/dotnet/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ done

# Install .NET versions and dependencies
# icu-devtools includes dependencies for .NET
check_packages wget ca-certificates icu-devtools
check_packages wget ca-certificates icu-devtools jq

for version in "${versions[@]}"; do
read -r clean_version quality < <(parse_version_and_quality "$version")
Expand Down
67 changes: 38 additions & 29 deletions src/dotnet/scripts/dotnet-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,49 @@
# Maintainer: The Dev Container spec maintainers
DOTNET_SCRIPTS=$(dirname "${BASH_SOURCE[0]}")
DOTNET_INSTALL_SCRIPT="$DOTNET_SCRIPTS/vendor/dotnet-install.sh"
DOTNET_RELEASES_INDEX_URL="https://builds.dotnet.microsoft.com/dotnet/release-metadata/releases-index.json"

# Prints the latest dotnet version in the specified channel
# Usage: fetch_latest_version_in_channel <channel> [<runtime>]
# Example: fetch_latest_version_in_channel "LTS"
# Example: fetch_latest_version_in_channel "6.0" "dotnet"
# Example: fetch_latest_version_in_channel "6.0" "aspnetcore"
fetch_latest_version_in_channel() {
local channel="$1"
local runtime="$2"
if [ "$runtime" = "dotnet" ]; then
wget -qO- "https://builds.dotnet.microsoft.com/dotnet/Runtime/$channel/latest.version"
elif [ "$runtime" = "aspnetcore" ]; then
wget -qO- "https://builds.dotnet.microsoft.com/dotnet/aspnetcore/Runtime/$channel/latest.version"
else
wget -qO- "https://builds.dotnet.microsoft.com/dotnet/Sdk/$channel/latest.version"
fi
}

# Prints the latest dotnet version
# Usage: fetch_latest_version [<runtime>]
# Prints the latest active dotnet version from the releases index.
# Usage: fetch_latest_version [<target>]
# With no target, resolves the latest SDK version.
# With "sdk", resolves the latest SDK version explicitly.
# With "dotnet" or "aspnetcore", resolves the latest runtime version.
# Note: the upstream releases index only distinguishes SDK vs runtime for
# latest resolution, so "dotnet" and "aspnetcore" currently resolve to the
# same version.
# Example: fetch_latest_version
# Example: fetch_latest_version "sdk"
# Example: fetch_latest_version "dotnet"
# Example: fetch_latest_version "aspnetcore"
fetch_latest_version() {
local runtime="$1"
local sts_version
local lts_version
sts_version=$(fetch_latest_version_in_channel "STS" "$runtime")
lts_version=$(fetch_latest_version_in_channel "LTS" "$runtime")
if [[ "$sts_version" > "$lts_version" ]]; then
echo "$sts_version"
else
echo "$lts_version"
fi
local target="$1"
local version_field=""
local releases_index=""

case "$target" in
""|sdk)
version_field="latest-sdk"
;;
dotnet|aspnetcore)
version_field="latest-runtime"
;;
*)
echo "Unsupported target '$target'. Expected 'sdk', 'dotnet', or 'aspnetcore'." >&2
return 1
;;
esac

releases_index="$(wget -qO- "$DOTNET_RELEASES_INDEX_URL")" || return $?

printf '%s\n' "$releases_index" \
| jq -er --arg version_field "$version_field" '
.["releases-index"]
| map(
select(."support-phase" == "active")
| .[$version_field]
)
| .[0]
'
}

# Installs a version of the .NET SDK
Expand Down
66 changes: 38 additions & 28 deletions test/dotnet/dotnet_helpers.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,48 @@
#!/bin/bash

# Prints the latest dotnet version in the specified channel
# Usage: fetch_latest_version_in_channel <channel> [<runtime>]
# Example: fetch_latest_version_in_channel "LTS"
# Example: fetch_latest_version_in_channel "6.0" "dotnet"
# Example: fetch_latest_version_in_channel "6.0" "aspnetcore"
fetch_latest_version_in_channel() {
local channel="$1"
local runtime="$2"
if [ "$runtime" = "dotnet" ]; then
wget -qO- "https://builds.dotnet.microsoft.com/dotnet/Runtime/$channel/latest.version"
elif [ "$runtime" = "aspnetcore" ]; then
wget -qO- "https://builds.dotnet.microsoft.com/dotnet/aspnetcore/Runtime/$channel/latest.version"
else
wget -qO- "https://builds.dotnet.microsoft.com/dotnet/Sdk/$channel/latest.version"
fi
}
DOTNET_RELEASES_INDEX_URL="https://builds.dotnet.microsoft.com/dotnet/release-metadata/releases-index.json"

# Prints the latest dotnet version
# Usage: fetch_latest_version [<runtime>]
# Prints the latest active dotnet version from the releases index.
# Usage: fetch_latest_version [<target>]
# With no target, resolves the latest SDK version.
# With "sdk", resolves the latest SDK version explicitly.
# With "dotnet" or "aspnetcore", resolves the latest runtime version.
# Note: the upstream releases index only distinguishes SDK vs runtime for
# latest resolution, so "dotnet" and "aspnetcore" currently resolve to the
# same version.
# Example: fetch_latest_version
# Example: fetch_latest_version "sdk"
# Example: fetch_latest_version "dotnet"
# Example: fetch_latest_version "aspnetcore"
fetch_latest_version() {
local runtime="$1"
local sts_version
local lts_version
sts_version=$(fetch_latest_version_in_channel "STS" "$runtime")
lts_version=$(fetch_latest_version_in_channel "LTS" "$runtime")
if [[ "$sts_version" > "$lts_version" ]]; then
echo "$sts_version"
else
echo "$lts_version"
fi
local target="$1"
local version_field=""
local releases_index=""

case "$target" in
""|sdk)
version_field="latest-sdk"
;;
dotnet|aspnetcore)
version_field="latest-runtime"
;;
*)
echo "Unsupported target '$target'. Expected 'sdk', 'dotnet', or 'aspnetcore'." >&2
return 1
;;
esac

releases_index="$(wget -qO- "$DOTNET_RELEASES_INDEX_URL")" || return $?

printf '%s\n' "$releases_index" \
| jq -er --arg version_field "$version_field" '
.["releases-index"]
| map(
select(."support-phase" == "active")
| .[$version_field]
)
| .[0]
'
}

# Asserts that the specified .NET SDK version is installed
Expand Down
2 changes: 1 addition & 1 deletion test/dotnet/install_dotnet_lts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ source dev-container-features-test-lib
source dotnet_env.sh
source dotnet_helpers.sh

expected=$(fetch_latest_version_in_channel "LTS")
expected=$(wget -qO- "https://builds.dotnet.microsoft.com/dotnet/Sdk/LTS/latest.version")

check "Latest LTS version installed" \
is_dotnet_sdk_version_installed "$expected"
Expand Down
2 changes: 1 addition & 1 deletion test/dotnet/install_dotnet_specific_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ source dev-container-features-test-lib
source dotnet_env.sh
source dotnet_helpers.sh

expected=$(fetch_latest_version_in_channel "10.0")
expected=$(wget -qO- "https://builds.dotnet.microsoft.com/dotnet/Sdk/10.0/latest.version")

check ".NET Core SDK 10.0 installed" \
is_dotnet_sdk_version_installed "$expected"
Expand Down
3 changes: 0 additions & 3 deletions test/dotnet/install_dotnet_workloads.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ source dev-container-features-test-lib
source dotnet_env.sh
source dotnet_helpers.sh

check "Aspire is installed" \
is_dotnet_workload_installed "aspire"

check "WASM tools are installed" \
is_dotnet_workload_installed "wasm-tools"

Expand Down
2 changes: 1 addition & 1 deletion test/dotnet/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"features": {
"dotnet": {
"version": "latest",
"workloads": "aspire, wasm-tools"
"workloads": "wasm-tools"
}
}
}
Expand Down
Loading