diff --git a/src/dotnet/NOTES.md b/src/dotnet/NOTES.md index ff52835b0..953372381 100644 --- a/src/dotnet/NOTES.md +++ b/src/dotnet/NOTES.md @@ -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" } } ``` diff --git a/src/dotnet/README.md b/src/dotnet/README.md index fecaeb3f3..8244b151d 100644 --- a/src/dotnet/README.md +++ b/src/dotnet/README.md @@ -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 @@ -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" } } ``` diff --git a/src/dotnet/install.sh b/src/dotnet/install.sh index a6bde1ebd..d2b06cd0e 100644 --- a/src/dotnet/install.sh +++ b/src/dotnet/install.sh @@ -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") diff --git a/src/dotnet/scripts/dotnet-helpers.sh b/src/dotnet/scripts/dotnet-helpers.sh index 2ef8796eb..d2dbc4534 100644 --- a/src/dotnet/scripts/dotnet-helpers.sh +++ b/src/dotnet/scripts/dotnet-helpers.sh @@ -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 [] -# 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 [] +# Prints the latest active dotnet version from the releases index. +# Usage: fetch_latest_version [] +# 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 diff --git a/test/dotnet/dotnet_helpers.sh b/test/dotnet/dotnet_helpers.sh index 01e554f66..abb0cca26 100644 --- a/test/dotnet/dotnet_helpers.sh +++ b/test/dotnet/dotnet_helpers.sh @@ -1,38 +1,48 @@ #!/bin/bash -# Prints the latest dotnet version in the specified channel -# Usage: fetch_latest_version_in_channel [] -# 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 [] +# Prints the latest active dotnet version from the releases index. +# Usage: fetch_latest_version [] +# 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 diff --git a/test/dotnet/install_dotnet_lts.sh b/test/dotnet/install_dotnet_lts.sh index da9175c15..a62c5937b 100644 --- a/test/dotnet/install_dotnet_lts.sh +++ b/test/dotnet/install_dotnet_lts.sh @@ -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" diff --git a/test/dotnet/install_dotnet_specific_release.sh b/test/dotnet/install_dotnet_specific_release.sh index 1ef587945..961cb47ab 100644 --- a/test/dotnet/install_dotnet_specific_release.sh +++ b/test/dotnet/install_dotnet_specific_release.sh @@ -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" diff --git a/test/dotnet/install_dotnet_workloads.sh b/test/dotnet/install_dotnet_workloads.sh index 37c86a2d4..c4885664a 100644 --- a/test/dotnet/install_dotnet_workloads.sh +++ b/test/dotnet/install_dotnet_workloads.sh @@ -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" diff --git a/test/dotnet/scenarios.json b/test/dotnet/scenarios.json index 62e2f1a46..52c35b2b0 100644 --- a/test/dotnet/scenarios.json +++ b/test/dotnet/scenarios.json @@ -89,7 +89,7 @@ "features": { "dotnet": { "version": "latest", - "workloads": "aspire, wasm-tools" + "workloads": "wasm-tools" } } }