-
Notifications
You must be signed in to change notification settings - Fork 704
Add scripts to download aspire-cli #10254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
3ffcd36
06552a2
c45b215
bc855ed
8c4edc4
372f899
0820d14
8f4d0bc
0621834
c8dccb8
6664feb
01ecfac
73b1379
877c329
6561c32
41544b0
affb837
95dfd0c
2fb6065
ae772b0
48b262f
f788557
3986ae1
7e6506f
c09d588
67908b4
e85ae0b
2a43c92
3baae6e
ef81d43
5b01fe0
323b9bc
205d15b
cd1d032
4d6e44e
a0dadea
d12589b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| #!/usr/bin/env pwsh | ||
|
|
||
| [CmdletBinding()] | ||
| param() | ||
|
|
||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| # Define supported combinations (script-level constant) | ||
| $script:SupportedCombinations = @( | ||
| "win-x86", | ||
| "win-x64", | ||
| "win-arm64", | ||
| "linux-x64", | ||
| "linux-arm64", | ||
| "linux-musl-x64", | ||
| "osx-x64", | ||
| "osx-arm64" | ||
| ) | ||
|
|
||
| # Function to detect OS | ||
| function Get-OperatingSystem { | ||
| if ($IsWindows -or ($PSVersionTable.PSVersion.Major -le 5)) { | ||
| return "win" | ||
| } | ||
| elseif ($IsLinux) { | ||
| # Check if it's musl-based (Alpine, etc.) | ||
| try { | ||
| $lddOutput = & ldd --version 2>&1 | Out-String | ||
| if ($lddOutput -match "musl") { | ||
| return "linux-musl" | ||
| } | ||
| else { | ||
| return "linux" | ||
| } | ||
| } | ||
| catch { | ||
| return "linux" | ||
| } | ||
| } | ||
| elseif ($IsMacOS) { | ||
| return "osx" | ||
| } | ||
| else { | ||
| return "unsupported" | ||
| } | ||
| } | ||
|
|
||
| # Function to detect architecture | ||
| function Get-Architecture { | ||
| $arch = [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture | ||
|
|
||
| switch ($arch) { | ||
| "X64" { return "x64" } | ||
| "Arm64" { return "arm64" } | ||
| "X86" { return "x86" } | ||
| default { return "unsupported" } | ||
| } | ||
| } | ||
|
|
||
| # Function to validate OS/arch combination | ||
| function Test-SupportedCombination { | ||
| param( | ||
| [string]$OS, | ||
| [string]$Architecture | ||
| ) | ||
|
|
||
| $combination = "$OS-$Architecture" | ||
|
|
||
| return $combination -in $script:SupportedCombinations | ||
| } | ||
|
|
||
| # Main function | ||
| function Main { | ||
| try { | ||
| # Detect OS and architecture | ||
| $os = Get-OperatingSystem | ||
| $arch = Get-Architecture | ||
|
|
||
| # Check for unsupported OS or architecture | ||
| if ($os -eq "unsupported") { | ||
| Write-Error "Error: Unsupported operating system: $([System.Environment]::OSVersion.Platform)" | ||
| exit 1 | ||
radical marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| if ($arch -eq "unsupported") { | ||
| Write-Error "Error: Unsupported architecture: $([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture)" | ||
| exit 1 | ||
| } | ||
|
|
||
| # Validate the combination | ||
| if (-not (Test-SupportedCombination -OS $os -Architecture $arch)) { | ||
| Write-Error "Error: Unsupported OS/architecture combination: $os-$arch" | ||
| Write-Error "Supported combinations: $($script:SupportedCombinations -join ', ')" | ||
| exit 1 | ||
| } | ||
|
|
||
| # Determine file extension based on OS | ||
| $extension = if ($os -eq "win") { "zip" } else { "tar.gz" } | ||
|
|
||
| # Construct the URL | ||
| $combination = "$os-$arch" | ||
| $url = "https://aka.ms/dotnet/9.0/daily/aspire-cli-$combination.$extension" | ||
radical marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # Output the URL | ||
| Write-Host "Downloading from: $url" | ||
|
|
||
| # Download the file | ||
| $filename = "aspire-cli-$combination.$extension" | ||
| Write-Host "Saving to: $filename" | ||
|
|
||
| try { | ||
| Invoke-WebRequest -Uri $url -OutFile $filename -MaximumRedirection 10 | ||
radical marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Write-Host "Download completed successfully: $filename" -ForegroundColor Green | ||
| } | ||
| catch { | ||
| Write-Error "Error: Failed to download $url - $($_.Exception.Message)" | ||
| exit 1 | ||
| } | ||
| } | ||
| catch { | ||
| Write-Error "An error occurred: $($_.Exception.Message)" | ||
| exit 1 | ||
| } | ||
| } | ||
|
|
||
| # Run main function | ||
| Main | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,145 @@ | ||||||
| #!/usr/bin/env bash | ||||||
|
|
||||||
| # get-aspire-cli.sh - Download the Aspire CLI for the current platform | ||||||
| # Usage: ./get-aspire-cli.sh | ||||||
|
|
||||||
| set -euo pipefail | ||||||
|
|
||||||
| # Define supported combinations (global constant) | ||||||
| readonly SUPPORTED_COMBINATIONS=( | ||||||
| "win-x86" | ||||||
| "win-x64" | ||||||
| "win-arm64" | ||||||
| "linux-x64" | ||||||
| "linux-arm64" | ||||||
| "linux-musl-x64" | ||||||
| "osx-x64" | ||||||
| "osx-arm64" | ||||||
| ) | ||||||
|
|
||||||
| # Function to detect OS | ||||||
| get_os() { | ||||||
| local uname_s | ||||||
| uname_s=$(uname -s) | ||||||
|
|
||||||
| case "$uname_s" in | ||||||
| Darwin*) | ||||||
| printf "osx" | ||||||
| ;; | ||||||
| Linux*) | ||||||
| # Check if it's musl-based (Alpine, etc.) | ||||||
| if ldd --version 2>&1 | grep -q musl; then | ||||||
radical marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| printf "linux-musl" | ||||||
| else | ||||||
| printf "linux" | ||||||
| fi | ||||||
| ;; | ||||||
| CYGWIN*|MINGW*|MSYS*) | ||||||
| printf "win" | ||||||
| ;; | ||||||
| *) | ||||||
| printf "unsupported" | ||||||
| return 1 | ||||||
| ;; | ||||||
| esac | ||||||
| } | ||||||
|
|
||||||
| # Function to detect architecture | ||||||
| get_arch() { | ||||||
| local uname_m | ||||||
| uname_m=$(uname -m) | ||||||
|
|
||||||
| case "$uname_m" in | ||||||
| x86_64|amd64) | ||||||
| printf "x64" | ||||||
| ;; | ||||||
| aarch64|arm64) | ||||||
| printf "arm64" | ||||||
| ;; | ||||||
| i386|i686) | ||||||
| printf "x86" | ||||||
| ;; | ||||||
| *) | ||||||
| printf "unsupported" | ||||||
| return 1 | ||||||
| ;; | ||||||
| esac | ||||||
| } | ||||||
|
|
||||||
| # Function to validate OS/arch combination | ||||||
| validate_combination() { | ||||||
| local os="$1" | ||||||
| local arch="$2" | ||||||
| local combination="${os}-${arch}" | ||||||
|
|
||||||
| local supported_combo | ||||||
| for supported_combo in "${SUPPORTED_COMBINATIONS[@]}"; do | ||||||
| if [[ "$combination" == "$supported_combo" ]]; then | ||||||
| return 0 | ||||||
| fi | ||||||
| done | ||||||
|
|
||||||
| return 1 | ||||||
| } | ||||||
|
|
||||||
| # Download the Aspire CLI for the current platform | ||||||
| download_aspire_cli() { | ||||||
| local url="$1" | ||||||
| local filename="$2" | ||||||
|
|
||||||
| printf "Downloading from: %s\n" "$url" | ||||||
| printf "Saving to: %s\n" "$filename" | ||||||
|
|
||||||
| if curl -fsSL -o "$filename" "$url"; then | ||||||
|
||||||
| printf "Download completed successfully: %s\n" "$filename" | ||||||
| return 0 | ||||||
| else | ||||||
| printf "Error: Failed to download %s\n" "$url" >&2 | ||||||
| return 1 | ||||||
| fi | ||||||
| } | ||||||
|
|
||||||
| # Main script | ||||||
| main() { | ||||||
| local os arch combination url filename | ||||||
|
|
||||||
| # Detect OS and architecture | ||||||
| if ! os=$(get_os); then | ||||||
| printf "Error: Unsupported operating system: %s\n" "$(uname -s)" >&2 | ||||||
| return 1 | ||||||
| fi | ||||||
|
|
||||||
| if ! arch=$(get_arch); then | ||||||
| printf "Error: Unsupported architecture: %s\n" "$(uname -m)" >&2 | ||||||
| return 1 | ||||||
| fi | ||||||
|
|
||||||
| # Validate the combination | ||||||
| if ! validate_combination "$os" "$arch"; then | ||||||
| combination="${os}-${arch}" | ||||||
| printf "Error: Unsupported OS/architecture combination: %s\n" "$combination" >&2 | ||||||
| printf "Supported combinations: %s\n" "${SUPPORTED_COMBINATIONS[*]}" >&2 | ||||||
| return 1 | ||||||
| fi | ||||||
|
|
||||||
| # Construct the URL and filename | ||||||
| combination="${os}-${arch}" | ||||||
|
|
||||||
| # Determine file extension based on OS | ||||||
| if [[ "$os" == "win" ]]; then | ||||||
| extension="zip" | ||||||
| else | ||||||
| extension="tar.gz" | ||||||
| fi | ||||||
|
Comment on lines
+553
to
+557
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the aspire/eng/clipack/Common.projitems Lines 6 to 7 in 853c918
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That will change with #10275 |
||||||
|
|
||||||
| url="https://aka.ms/dotnet/9.0/daily/aspire-cli-${combination}.${extension}" | ||||||
| filename="aspire-cli-${combination}.${extension}" | ||||||
|
|
||||||
| # Download the file | ||||||
| download_aspire_cli "$url" "$filename" | ||||||
| } | ||||||
|
|
||||||
| # Run main function if script is executed directly | ||||||
| if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then | ||||||
| main "$@" | ||||||
| fi | ||||||
Uh oh!
There was an error while loading. Please reload this page.