Skip to content
Merged
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
15 changes: 14 additions & 1 deletion eng/scripts/get-aspire-cli-pr.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
.PARAMETER HiveOnly
Only install NuGet packages to the hive, skip CLI download

.PARAMETER SkipPath
Do not add the install path to PATH environment variable (useful for portable installs)

.PARAMETER KeepArchive
Keep downloaded archive files after installation

Expand Down Expand Up @@ -63,6 +66,9 @@
.EXAMPLE
.\get-aspire-cli-pr.ps1 1234 -UseInsiders

.EXAMPLE
.\get-aspire-cli-pr.ps1 1234 -SkipPath

.EXAMPLE
Piped execution
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } <PR_NUMBER>
Expand Down Expand Up @@ -107,6 +113,9 @@ param(
[Parameter(HelpMessage = "Install extension to VS Code Insiders instead of VS Code")]
[switch]$UseInsiders,

[Parameter(HelpMessage = "Do not add the install path to PATH environment variable (useful for portable installs)")]
[switch]$SkipPath,

[Parameter(HelpMessage = "Keep downloaded archive files after installation")]
[switch]$KeepArchive
)
Expand Down Expand Up @@ -1089,7 +1098,11 @@ function Start-DownloadAndInstall {

# Update PATH environment variables
if (-not $HiveOnly) {
Update-PathEnvironment -CliBinDir $cliBinDir
if ($SkipPath) {
Write-Message "Skipping PATH configuration due to -SkipPath flag" -Level Info
} else {
Update-PathEnvironment -CliBinDir $cliBinDir
}
}
}

Expand Down
25 changes: 18 additions & 7 deletions eng/scripts/get-aspire-cli-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ DRY_RUN=false
HIVE_ONLY=false
SKIP_EXTENSION_INSTALL=false
USE_INSIDERS=false
SKIP_PATH=false
HOST_OS="unset"

# Function to show help
Expand Down Expand Up @@ -67,6 +68,7 @@ USAGE:
--hive-only Only install NuGet packages to the hive, skip CLI download
--skip-extension. Skip VS Code extension download and installation
--use-insiders Install extension to VS Code Insiders instead of VS Code
--skip-path Do not add the install path to PATH environment variable (useful for portable installs)
-v, --verbose Enable verbose output
-k, --keep-archive Keep downloaded archive files after installation
--dry-run Show what would be done without performing actions
Expand All @@ -80,6 +82,7 @@ EXAMPLES:
./get-aspire-cli-pr.sh 1234 --hive-only
./get-aspire-cli-pr.sh 1234 --skip-extension
./get-aspire-cli-pr.sh 1234 --use-insiders
./get-aspire-cli-pr.sh 1234 --skip-path
./get-aspire-cli-pr.sh 1234 --dry-run

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- <PR_NUMBER>
Expand Down Expand Up @@ -190,6 +193,10 @@ parse_args() {
USE_INSIDERS=true
shift
;;
--skip-path)
SKIP_PATH=true
shift
;;
--dry-run)
DRY_RUN=true
shift
Expand Down Expand Up @@ -1058,14 +1065,18 @@ fi

# Add to shell profile for persistent PATH
if [[ "$HIVE_ONLY" != true ]]; then
add_to_shell_profile "$cli_install_dir" "$INSTALL_PATH_UNEXPANDED"
if [[ "$SKIP_PATH" == true ]]; then
say_info "Skipping PATH configuration due to --skip-path flag"
else
add_to_shell_profile "$cli_install_dir" "$INSTALL_PATH_UNEXPANDED"

# Add to current session PATH, if the path is not already in PATH
if [[ ":$PATH:" != *":$cli_install_dir:"* ]]; then
if [[ "$DRY_RUN" == true ]]; then
say_info "[DRY RUN] Would add $cli_install_dir to PATH"
else
export PATH="$cli_install_dir:$PATH"
# Add to current session PATH, if the path is not already in PATH
if [[ ":$PATH:" != *":$cli_install_dir:"* ]]; then
if [[ "$DRY_RUN" == true ]]; then
say_info "[DRY RUN] Would add $cli_install_dir to PATH"
else
export PATH="$cli_install_dir:$PATH"
fi
fi
fi
fi
13 changes: 11 additions & 2 deletions eng/scripts/get-aspire-cli.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ param(
[Parameter(HelpMessage = "Install extension to VS Code Insiders instead of VS Code")]
[switch]$UseInsiders,

[Parameter(HelpMessage = "Do not add the install path to PATH environment variable (useful for portable installs)")]
[switch]$SkipPath,

[Parameter(HelpMessage = "Show help message")]
[switch]$Help
)
Expand Down Expand Up @@ -139,6 +142,7 @@ PARAMETERS:
-Architecture <string> Architecture (default: auto-detect)
-InstallExtension Install VS Code extension along with the CLI
-UseInsiders Install extension to VS Code Insiders instead of VS Code (requires -InstallExtension)
-SkipPath Do not add the install path to PATH environment variable (useful for portable installs)
-KeepArchive Keep downloaded archive files and temporary directory after installation
-Help Show this help message

Expand All @@ -161,6 +165,7 @@ EXAMPLES:
.\get-aspire-cli.ps1 -OS "linux" -Architecture "x64"
.\get-aspire-cli.ps1 -InstallExtension
.\get-aspire-cli.ps1 -InstallExtension -UseInsiders
.\get-aspire-cli.ps1 -SkipPath
.\get-aspire-cli.ps1 -KeepArchive
.\get-aspire-cli.ps1 -WhatIf
.\get-aspire-cli.ps1 -Help
Expand Down Expand Up @@ -1070,8 +1075,12 @@ function Start-AspireCliInstallation {
# Download and install the Aspire CLI
$targetOS = Install-AspireCli -InstallPath $resolvedInstallPath -Version $Version -Quality $Quality -OS $OS -Architecture $Architecture

# Update PATH environment variables
Update-PathEnvironment -InstallPath $resolvedInstallPath -TargetOS $targetOS
# Update PATH environment variables unless -SkipPath is specified
if ($SkipPath) {
Write-Message "Skipping PATH configuration due to -SkipPath flag" -Level Info
} else {
Update-PathEnvironment -InstallPath $resolvedInstallPath -TargetOS $targetOS
}
}
catch {
# Display clean error message without stack trace
Expand Down
45 changes: 28 additions & 17 deletions eng/scripts/get-aspire-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ KEEP_ARCHIVE=false
DRY_RUN=false
INSTALL_EXTENSION=false
USE_INSIDERS=false
SKIP_PATH=false
DEFAULT_QUALITY="release"
EXTENSION_ARTIFACT_NAME="aspire-vscode.vsix.zip"

Expand Down Expand Up @@ -57,6 +58,7 @@ USAGE:
--arch ARCH Architecture (default: auto-detect)
--install-extension Install VS Code extension along with the CLI
--use-insiders Install extension to VS Code Insiders instead of VS Code (requires --install-extension)
--skip-path Do not add the install path to PATH environment variable (useful for portable installs)
-k, --keep-archive Keep downloaded archive files and temporary directory after installation
--dry-run Show what would be done without actually performing any actions
-v, --verbose Enable verbose output
Expand Down Expand Up @@ -138,6 +140,10 @@ parse_args() {
USE_INSIDERS=true
shift
;;
--skip-path)
SKIP_PATH=true
shift
;;
-k|--keep-archive)
KEEP_ARCHIVE=true
shift
Expand Down Expand Up @@ -994,26 +1000,31 @@ if ! download_and_install_archive "$temp_dir"; then
exit 1
fi

# Handle GitHub Actions environment
if [[ -n "${GITHUB_ACTIONS:-}" ]] && [[ "${GITHUB_ACTIONS}" == "true" ]]; then
if [[ -n "${GITHUB_PATH:-}" ]]; then
if [[ "$DRY_RUN" == true ]]; then
say_info "[DRY RUN] Would add $INSTALL_PATH to \$GITHUB_PATH"
else
echo "$INSTALL_PATH" >> "$GITHUB_PATH"
say_verbose "Added $INSTALL_PATH to \$GITHUB_PATH"
# Skip PATH configuration if --skip-path is set
if [[ "$SKIP_PATH" != true ]]; then
# Handle GitHub Actions environment
if [[ -n "${GITHUB_ACTIONS:-}" ]] && [[ "${GITHUB_ACTIONS}" == "true" ]]; then
if [[ -n "${GITHUB_PATH:-}" ]]; then
if [[ "$DRY_RUN" == true ]]; then
say_info "[DRY RUN] Would add $INSTALL_PATH to \$GITHUB_PATH"
else
echo "$INSTALL_PATH" >> "$GITHUB_PATH"
say_verbose "Added $INSTALL_PATH to \$GITHUB_PATH"
fi
fi
fi
fi

# Add to shell profile for persistent PATH
add_to_shell_profile "$INSTALL_PATH" "$INSTALL_PATH_UNEXPANDED"
# Add to shell profile for persistent PATH
add_to_shell_profile "$INSTALL_PATH" "$INSTALL_PATH_UNEXPANDED"

# Add to current session PATH, if the path is not already in PATH
if [[ ":$PATH:" != *":$INSTALL_PATH:"* ]]; then
if [[ "$DRY_RUN" == true ]]; then
say_info "[DRY RUN] Would add $INSTALL_PATH to PATH"
else
export PATH="$INSTALL_PATH:$PATH"
# Add to current session PATH, if the path is not already in PATH
if [[ ":$PATH:" != *":$INSTALL_PATH:"* ]]; then
if [[ "$DRY_RUN" == true ]]; then
say_info "[DRY RUN] Would add $INSTALL_PATH to PATH"
else
export PATH="$INSTALL_PATH:$PATH"
fi
fi
else
say_info "Skipping PATH configuration due to --skip-path flag"
fi