Skip to content

Commit 8895eb3

Browse files
authored
[dotnet] - Fixing the dotnet smoke test issue with changes in test script. (#1335)
* Fixing the dotnet smoke test issue with changes in test script. * Version bump
1 parent b89a41f commit 8895eb3

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

src/dotnet/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "dotnet",
3-
"version": "2.2.1",
3+
"version": "2.2.2",
44
"name": "Dotnet CLI",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/dotnet",
66
"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.",

test/dotnet/dotnet_helpers.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,44 @@ fetch_latest_version_in_channel() {
1717
fi
1818
}
1919

20+
# Function to resolve the actual version from an aka.ms URL
21+
resolve_version_from_aka_ms() {
22+
local normalized_channel="${1:-LTS}" # defaulting to LTS channel
23+
local normalized_product="dotnet-sdk"
24+
local normalized_os="linux"
25+
26+
# Dynamically determine the architecture
27+
local normalized_architecture
28+
normalized_architecture=$(uname -m)
29+
case "$normalized_architecture" in
30+
x86_64) normalized_architecture="x64" ;;
31+
aarch64) normalized_architecture="arm64" ;;
32+
arm*) normalized_architecture="arm" ;;
33+
*)
34+
echo "Unsupported architecture: $normalized_architecture"
35+
return 1
36+
;;
37+
esac
38+
39+
# Construct the aka.ms link
40+
local aka_ms_link="https://aka.ms/dotnet/$normalized_channel/$normalized_product-$normalized_os-$normalized_architecture.tar.gz"
41+
echo "Constructed aka.ms link: $aka_ms_link"
42+
43+
# Resolve the redirect URL using curl
44+
local resolved_url
45+
resolved_url=$(curl -s -L -o /dev/null -w "%{url_effective}" "$aka_ms_link")
46+
echo "Resolved URL: $resolved_url"
47+
48+
# Extract the version from the resolved URL
49+
IFS='/'
50+
read -ra pathElems <<< "$resolved_url"
51+
local count=${#pathElems[@]}
52+
local specific_version="${pathElems[count-2]}"
53+
unset IFS
54+
55+
echo "Extracted version: $specific_version"
56+
}
57+
2058
# Prints the latest dotnet version
2159
# Usage: fetch_latest_version [<runtime>]
2260
# Example: fetch_latest_version

test/dotnet/install_dotnet_lts.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ source dev-container-features-test-lib
1313
source dotnet_env.sh
1414
source dotnet_helpers.sh
1515

16-
expected=$(fetch_latest_version_in_channel "LTS")
16+
# Changing it as the dotnet SDK CDN url is not showing the right version for LTS
17+
expected=$(resolve_version_from_aka_ms "LTS" | cut -d' ' -f3)
1718

1819
check "Latest LTS version installed" \
1920
is_dotnet_sdk_version_installed "$expected"

0 commit comments

Comments
 (0)