Skip to content

Commit

Permalink
A bit more clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
IEvangelist committed Oct 24, 2024
1 parent a73f680 commit 42da7b6
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions docs/app-host/eventing.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ All of the preceding events are analogous to the [app host life cycles](xref:dot

To subscribe to the built-in app host events, use the eventing API. After you have a distributed application builder instance, walk up to the <xref:Aspire.Hosting.IDistributedApplicationBuilder.Eventing?displayProperty=nameWithType> property and call the <xref:Aspire.Hosting.Eventing.IDistributedApplicationEventing.Subscribe``1(System.Func{``0,System.Threading.CancellationToken,System.Threading.Tasks.Task})> API. Consider the following sample app host _Program.cs_ file:

:::code source="snippets/AspireApp/AspireApp.AppHost/Program.cs":::
:::code source="snippets/AspireApp/AspireApp.AppHost/Program.cs" highlight="17-25,27-35,37-45":::

The preceding code is based on the starter template with the addition of the subscribe calls. The `Subscribe<T>` API returns a <xref:Aspire.Hosting.Eventing.DistributedApplicationEventSubscription> instance that you can use to unsubscribe from the event. It's common to discard these, as you don't usually need to unsubscribe from events as the entire app is torn down when the app host is shut down.

When the app host is run, by the time the .NET Aspire dashboard is displayed, you should see the following log output in the console:

:::code language="Output" source="snippets/AspireApp/AspireApp.AppHost/Console.txt" highlight="2,10,16":::
:::code language="plaintext" source="snippets/AspireApp/AspireApp.AppHost/Console.txt" highlight="2,10,16":::

The log output confirms that event handlers are executed in the order of the app host life cycle events. The subscription order doesn't affect execution order. The `BeforeStartEvent` is triggered first, followed by `AfterEndpointsAllocatedEvent`, and finally `AfterResourcesCreatedEvent`.

Expand All @@ -45,7 +45,7 @@ In addition to the app host events, you can also subscribe to resource events. R

To subscribe to resource events, use the eventing API. After you have a distributed application builder instance, walk up to the <xref:Aspire.Hosting.IDistributedApplicationBuilder.Eventing?displayProperty=nameWithType> property and call the <xref:Aspire.Hosting.Eventing.IDistributedApplicationEventing.Subscribe``1(Aspire.Hosting.ApplicationModel.IResource,System.Func{``0,System.Threading.CancellationToken,System.Threading.Tasks.Task})> API. Consider the following sample app host _Program.cs_ file:

:::code source="snippets/AspireApp/AspireApp.ResourceAppHost/Program.cs":::
:::code source="snippets/AspireApp/AspireApp.ResourceAppHost/Program.cs" highlight="8-17,19-28":::

The preceding code subscribes to the `ConnectionStringAvailableEvent` and `BeforeResourceStartedEvent` events on the `cache` resource. When <xref:Aspire.Hosting.RedisBuilderExtensions.AddRedis*> is called, it returns an <xref:Aspire.Hosting.ApplicationModel.IResourceBuilder`1> where `T` is a <xref:Aspire.Hosting.ApplicationModel.RedisResource>. The resource builder exposes the resource as the <xref:Aspire.Hosting.ApplicationModel.IResourceBuilder`1.Resource?displayProperty=nameWithType> property. This resource is then passed to the `Subscribe` API to subscribe to the events on the resource.

Expand Down
4 changes: 2 additions & 2 deletions docs/fundamentals/aspire-sdk-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The .NET Aspire templates are available in the [📦 Aspire.ProjectTemplates](ht

::zone pivot="visual-studio"

The .NET Aspire templates are installed automatically when you install Visual Studio 17.12 or later.
The .NET Aspire templates are installed automatically when you install Visual Studio 17.9 or later.

:::zone-end
:::zone pivot="vscode,dotnet-cli"
Expand All @@ -33,7 +33,7 @@ dotnet new install Aspire.ProjectTemplates

::zone pivot="visual-studio"

The .NET Aspire templates are installed automatically when you install Visual Studio 17.12 or later. To see what .NET Aspire templates are available, select **File** > **New** > **Project** in Visual Studio, and search for "Aspire" in the search bar (<kbd>Alt</kbd>+<kbd>S</kbd>). You'll see a list of available .NET Aspire project templates:
The .NET Aspire templates are installed automatically when you install Visual Studio 17.9 or later. To see what .NET Aspire templates are available, select **File** > **New** > **Project** in Visual Studio, and search for "Aspire" in the search bar (<kbd>Alt</kbd>+<kbd>S</kbd>). You'll see a list of available .NET Aspire project templates:

:::image type="content" source="media/vs-create-dotnet-aspire-proj.png" alt-text="Visual Studio: Create new project and search for 'Aspire'." lightbox="media/vs-create-dotnet-aspire-proj.png":::

Expand Down
6 changes: 3 additions & 3 deletions docs/fundamentals/setup-tooling.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ To work with .NET Aspire, you need the following installed locally:
- An OCI compliant container runtime, such as:
- [Docker Desktop](https://www.docker.com/products/docker-desktop) or [Podman](https://podman.io/). For more information, see [Container runtime](#container-runtime).
- An Integrated Developer Environment (IDE) or code editor, such as:
- [Visual Studio 2022](https://visualstudio.microsoft.com/vs/) version 17.12 or higher (Optional)
- [Visual Studio 2022](https://visualstudio.microsoft.com/vs/) version 17.9 or higher (Optional)
- [Visual Studio Code](https://code.visualstudio.com/) (Optional)
- [C# Dev Kit: Extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) (Optional)
- [JetBrains Rider with .NET Aspire Plugin](https://blog.jetbrains.com/dotnet/2024/02/19/jetbrains-rider-and-the-net-aspire-plugin/)

:::zone pivot="visual-studio"

Visual Studio 2022 17.12 or higher includes the latest [.NET Aspire SDK](dotnet-aspire-sdk.md) by default when you install the Web & Cloud workload. To verify that you have the .NET Aspire SDK installed, ...
Visual Studio 2022 17.9 or higher includes the latest [.NET Aspire SDK](dotnet-aspire-sdk.md) by default when you install the Web & Cloud workload. To verify that you have the .NET Aspire SDK installed, ...

If you have an earlier version of Visual Studio 2022, you can either upgrade to Visual Studio 2022 17.12 or you can install the .NET Aspire SDK using the following steps:
If you have an earlier version of Visual Studio 2022, you can either upgrade to Visual Studio 2022 17.9 or you can install the .NET Aspire SDK using the following steps:

To install the .NET Aspire workload in Visual Studio 2022, use the Visual Studio installer.

Expand Down
2 changes: 1 addition & 1 deletion docs/includes/aspire-prereqs.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To work with .NET Aspire, you need the following installed locally:
- An OCI compliant container runtime, such as:
- [Docker Desktop](https://www.docker.com/products/docker-desktop) or [Podman](https://podman.io/).
- An Integrated Developer Environment (IDE) or code editor, such as:
- [Visual Studio 2022](https://visualstudio.microsoft.com/vs/) version 17.12 or higher (Optional)
- [Visual Studio 2022](https://visualstudio.microsoft.com/vs/) version 17.9 or higher (Optional)
- [Visual Studio Code](https://code.visualstudio.com/) (Optional)
- [C# Dev Kit: Extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) (Optional)

Expand Down
2 changes: 2 additions & 0 deletions docs/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ items:
href: get-started/add-aspire-existing-app.md
- name: Setup and tooling
href: fundamentals/setup-tooling.md
- name: .NET Aspire SDK
href: fundamentals/dotnet-aspire-sdk.md
- name: What's new in .NET Aspire
href: whats-new/index.yml
- name: Upgrade to .NET Aspire 9.0
Expand Down
2 changes: 1 addition & 1 deletion docs/whats-new/dotnet-aspire-9-release-candidate-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ In order to upgrade an existing project to .NET Aspire 9 RC1, you need to update
</Project>
```

That's it! You've successfully upgraded your project to .NET Aspire 9 RC1. If you're using Visual Studio, it's recommended to upgrade to version 17.12 Preview 3 or later in order to take advantage of the new features and improvements for .NET Aspire 9 RC1.
That's it! You've successfully upgraded your project to .NET Aspire 9 RC1. If you're using Visual Studio, it's recommended to upgrade to version 17.9 Preview 3 or later in order to take advantage of the new features and improvements for .NET Aspire 9 RC1.

### Upgrade an existing project to .NET Aspire 9 RC1 using the Upgrade Assistant

Expand Down

0 comments on commit 42da7b6

Please sign in to comment.