Skip to content
Closed
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
64 changes: 64 additions & 0 deletions src/dotnetaspire/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

# .NET Aspire (dotnetaspire)

This Feature installs .NET Aspire and if necessary the .NET (dotnet) that it depends on. Options are provided to choose a different version or additional versions.

## OS Support

This Feature should work on recent versions of Debian/Ubuntu-based distributions that support .NET and have the `apt` package manager installed

`bash` is required to execute the `install.sh` script.

## Example Usage

```json
"features": {
"ghcr.io/devcontainers/features/dotnetaspire:1": {}
}
```

## Options

| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|
| version | .NET Aspire version. Use 'latest' for the latest supported version, '9.0' for the 9.0 version, 'X.Y' or 'X.Y.Z' for a specific version, or 'latest-daily' for the latest unsupported build. | string | latest |

## Customizations

### VS Code Extensions

- `ms-dotnettools.csdevkit`

## Configuration examples

Installing only the latest .NET Aspire version (the default).

``` jsonc
"features": {
"ghcr.io/devcontainers/features/dotnetaspire:1": "latest" // or "" or {}
}
```

Installing .NET Aspire version 9.0.

``` jsonc
"features": {
"ghcr.io/devcontainers/features/dotnetaspire:1": "9.0" // or "" or {}
}
```

Installing the latest .NET Aspire unsupported build.

``` jsonc
"features": {
"ghcr.io/devcontainers/features/dotnetaspire:1": "latest-daily" // or "" or {}
}
```


## OS Support

This Feature should work on recent versions of Debian/Ubuntu-based distributions with the `apt` package manager installed.

`bash` is required to execute the `install.sh` script.

42 changes: 42 additions & 0 deletions src/dotnetaspire/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"id": "dotnetaspire",
"version": "1.0.0",
"name": ".NET Aspire",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/dotnetaspire",
"description": "Installs .NET Aspire. See https://aka.ms/dotnetaspire",
"options": {
"version": {
"type": "string",
"proposals": [
"latest daily",
"latest",
"9.0",
],
"default": "9.0",
"description": "Select or enter a .NET Aspire version. Use 'latest' for the latest supported version, '9.0' for the 9.0 version, 'X.Y' or 'X.Y.Z' for a specific version, or 'latest-daily' for the latest unsupported build."
},
},
"customizations": {
"vscode": {
"extensions": [
"ms-dotnettools.csdevkit",
"ms-azuretools.vscode-bicep",
"GitHub.copilot-chat",
"GitHub.copilot"
],
"settings": {
"remote.autoForwardPorts": true,
"remote.autoForwardPortsSource": "hybrid",
"remote.otherPortsAttributes": {
"onAutoForward": "ignore"
}
}
}
},
"dependsOn": {
"ghcr.io/devcontainers/features/dotnet": {
"version": "8.0",
"additionalVersions": "9.0"
}
}
}
49 changes: 49 additions & 0 deletions src/dotnetaspire/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash

#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
#
# Docs: https://github.com/devcontainers/features/tree/main/src/dotnet
# Maintainer: The .NET Aspire team at https://github.com/dotnet/aspire

set -e

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

if [[ ! $VERSION =~ ^(9\.0|latest|latest-daily)$ ]]; then
echo "Error: VERSION must be either '9.0', '9.0.0', 'latest', or 'latest-daily' not: '$VERSION'."
exit 1
fi

if [[ $VERSION =~ ^(9\.0|9\.0\.0|latest)$ ]]; then
VERSION="9.0.0"
fi

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

# Before .NET Aspire 9.0 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\.0\.0)$ ]]; then
dotnet new install Aspire.ProjectTemplates::$VERSION
else
# 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

# If you use Package Source Mapping, you'll also need to add the following mappings to your NuGet.config
# <packageSourceMapping>
# <packageSource key="dotnet9">
# <package pattern="Aspire.*" />
# <package pattern="Microsoft.Extensions.ServiceDiscovery*" />
# <package pattern="Microsoft.Extensions.Http.Resilience" />
# </packageSource>
# </packageSourceMapping>

dotnet new install Aspire.ProjectTemplates::*-* --force
fi

echo "... done activating feature '.NET Aspire' version: $VERSION"
4 changes: 4 additions & 0 deletions test/dotnetaspire/dotnet_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
export DOTNET_NOLOGO=true
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
export DOTNET_GENERATE_ASPNET_CERTIFICATE=false
1 change: 1 addition & 0 deletions test/dotnetaspire/install_dotnetaspire_exact_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/usr/bin/env bash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/usr/bin/env bash
1 change: 1 addition & 0 deletions test/dotnetaspire/install_dotnetaspire_latest_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/usr/bin/env bash
26 changes: 26 additions & 0 deletions test/dotnetaspire/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"install_dotnetaspire_exact_version": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"dotnetaspire": {
"version": "9.0"
}
}
},
"install_dotnetaspire_latest_version": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"dotnetaspire": {
"version": "latest"
}
}
},
"install_dotnetaspire_latest_daily_version": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"dotnetaspire": {
"version": "latest-daily"
}
}
}
}
24 changes: 24 additions & 0 deletions test/dotnetaspire/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

set -e

# Run tests with `devcontainer features test -f dotnetaspire` in the parent of the src and test folders.

source dev-container-features-test-lib
source dotnet_env.sh

check "dotnet is installed in DOTNET_ROOT and execute permission is granted" \
test -x "$DOTNET_ROOT/dotnet"

check "dotnet 8.0 is installed" \
test "$($DOTNET_ROOT/dotnet --info | grep '8.0.')"

check "dotnet 9.0 is installed" \
test "$($DOTNET_ROOT/dotnet --info | grep '9.0.')"

check "dotnetaspire templates are installed" \
test "$DOTNET_ROOT/dotnet new aspire"

# There isn't currently a good way to check what version of the templates was installed.

reportResults