Skip to content

Adding support to install Aspire CLI #10

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
11 changes: 8 additions & 3 deletions src/dotnetaspire/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "dotnetaspire",
"version": "1.1.0",
"version": "1.2.0",
"name": ".NET Aspire",
"documentationURL": "https://github.com/dotnet/aspire-devcontainer-feature",
"description": "Installs Aspire. See https://aka.ms/dotnetaspire",
Expand All @@ -10,11 +10,16 @@
"proposals": [
"latest daily",
"latest",
"9.3",
"9.3"
],
"default": "latest",
"description": "Select or enter an Aspire version. Use 'latest' for the latest supported version, '9.3.1' for the 9.3.1 version, 'X.Y' or 'X.Y.Z' for a specific version, or 'latest-daily' for the latest unsupported build."
},
"installCli": {
"type": "boolean",
"default": true,
"description": "Whether to install the Aspire CLI."
}
},
"customizations": {
"vscode": {
Expand All @@ -38,4 +43,4 @@
"version": "latest"
}
}
}
}
27 changes: 19 additions & 8 deletions src/dotnetaspire/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,30 @@

set -e

# Set the current latest Aspire version here
ASPIRE_LATEST_VERSION="9.3.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@radical @joperezr - is there a way we can make this more data driven? Kind of like how https://builds.dotnet.microsoft.com/dotnet/release-metadata/releases-index.json works.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we can consider creating a blob with the version that we push to storage at a well-known location, and then having scripts just pull that blob to get the latest version.


# default to latest if not specified
VERSION="${VERSION:-"latest"}"
INSTALL_CLI="${INSTALLCLI:-"true"}"

if [[ ! $VERSION =~ ^(9\.1|latest|latest-daily)$ ]]; then
echo "Error: VERSION must be either '9.1', '9.1.0', 'latest', or 'latest-daily' not: '$VERSION'."
# Acceptable versions: 9.x, 9.x.x, latest, latest-daily
if [[ ! $VERSION =~ ^(9\.[0-9]+(\.[0-9]+)?|latest|latest-daily)$ ]]; then
echo "Error: VERSION must be a valid Aspire 9.x version (e.g., '9.1', '9.2.1'), 'latest', or 'latest-daily', not: '$VERSION'."
exit 1
fi

if [[ $VERSION =~ ^(9\.1|9\.1\.0|latest)$ ]]; then
VERSION="9.1.0"
# Map 'latest' to the current latest version
if [[ $VERSION == "latest" ]]; then
VERSION="$ASPIRE_LATEST_VERSION"
fi

echo "Activating feature '.NET Aspire' version: $VERSION"

# Before .NET Aspire 9.1 install required `dotnet workload`: this is no longer necessary, as Aspire is
# installed when restoring Aspire projects. It's only necessary to install the appropriate version of the templates.


if [[ $VERSION =~ ^(9\.1\.0)$ ]]; then
dotnet new install --force Aspire.ProjectTemplates::$VERSION
else
if [[ $VERSION == "latest-daily" ]]; then
# https://github.com/dotnet/aspire/blob/main/docs/using-latest-daily.md
dotnet nuget add source --name dotnet9 https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json

Expand All @@ -44,6 +47,14 @@ else
# </packageSourceMapping>

dotnet new install Aspire.ProjectTemplates::*-* --force
else
dotnet new install --force Aspire.ProjectTemplates::$VERSION
fi

# Optionally install the Aspire CLI if requested
if [[ "${INSTALL_CLI,,}" == "true" ]]; then
echo "Installing Aspire CLI (prerelease)..."
dotnet tool install --global aspire.cli --prerelease
fi

echo "... done activating feature '.NET Aspire' version: $VERSION"