.NET Aspire setup and tooling

.NET Aspire includes tooling to help you create and configure cloud-native apps. The tooling includes useful starter project templates and other features to streamline getting started with .NET Aspire for both Visual Studio and CLI workflows. In the sections ahead, you'll learn how to work with .NET Aspire tooling and explore the following tasks:

  • Install .NET Aspire and its dependencies
  • Create starter project templates using Visual Studio or the .NET CLI
  • Install .NET Aspire components
  • Work with the .NET Aspire dashboard

Install .NET Aspire

To work with .NET Aspire, you'll need the following installed locally:

The .NET Aspire workload installs internal dependencies and makes available other tooling, such as project templates and Visual Studio features. There are two ways to install the .NET Aspire workload. If you prefer to use Visual Studio Code, follow the .NET CLI instructions:

Visual Studio 2022 17.10 Preview 1 or higher includes the .NET Aspire preview 3 workload by default. To verify that you have the .NET Aspire workload installed, run the following command:

dotnet workload list

If you have an earlier version of Visual Studio 2022 Preview, you can either upgrade to Visual Studio 2022 17.10 Preview 1 or you can install the .NET Aspire workload using the following steps:

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

  1. Open the Visual Studio Installer.

  2. Select Modify next to Visual Studio 2022 Preview.

  3. Select the ASP.NET and web development workload.

  4. On the Installation details panel, select .NET Aspire SDK (Preview).

  5. Select Modify to install the .NET Aspire component.

    A screenshot showing how to install the .NET Aspire workload with the Visual Studio installer.

  6. To ensure that you install the latest version of the .NET Aspire workload, run the following dotnet workload update command before you install .NET Aspire:

    dotnet workload update
    
  7. To install the .NET Aspire workload from the .NET CLI, use the dotnet workload install command:

    dotnet workload install aspire
    
  8. To check your version of .NET Aspire, run this command:

    dotnet workload list
    

.NET Aspire project templates

Note

The .NET 9.0 SDK causes issues with the .NET Aspire workloads ability to display templates, and create projects from the templates. If you're using .NET 9.0, know that your ability to create new .NET Aspire apps is currently limited. For more information, see .NET Aspire preview-3 cannot create app when .NET 9 is installed and .NET Aspire preview-3 installed with Visual Studio 17.10 doesn't show templates.

The .NET Aspire workload makes available .NET Aspire project templates. These project templates allow you to create new apps pre-configured with the .NET Aspire project structure and default settings. These projects also provide a unified debugging experience across the different resources of your app.

There are currently two project templates available:

  • .NET Aspire Application: A minimal .NET Aspire app that includes the following:

    • AspireSample.AppHost: An orchestrator project designed to connect and configure the different projects and services of your app.

    • AspireSample.ServiceDefaults: A .NET Aspire shared project to manage configurations that are reused across the projects in your solution related to resilience, service discovery, and telemetry.

  • .NET Aspire Starter Application: In addition to the .AppHost and .ServiceDefaults projects, the .NET Aspire Starter Application also includes the following:

    • AspireSample.ApiService: An ASP.NET Core Minimal API project is used to provide data to the frontend. This project depends on the shared AspireSample.ServiceDefaults project.

    • AspireSample.Web: An ASP.NET Core Blazor App project with default .NET Aspire service configurations, this project depends on the AspireSample.ServiceDefaults project.

Use Visual Studio or the .NET CLI to create new apps using these project templates. Explore additional .NET Aspire project templates in the .NET Aspire samples repository.

To create a .NET Aspire project using Visual Studio, search for Aspire in the Visual Studio new project window and select your desired template.

The .NET Aspire project templates in Visual Studio.

.NET Aspire dashboard

.NET Aspire project templates also include a useful dashboard that can be used to monitor and inspect various aspects of your app, such as logs, traces, and environment configurations. This dashboard is designed to improve the local development experience and provides an overview of the overall state and structure of your app.

The .NET Aspire dashboard is only visible while the app is running and starts automatically when you start the .AppHost project. Visual Studio launches both your app and the .NET Aspire dashboard for you automatically in your browser. If you start the app using the .NET CLI, copy and paste the dashboard URL from the output into your browser.

A screenshot showing how to launch the dashboard using the CLI.

The left navigation provides links to the different parts of the dashboard, each of which you'll explore in the following sections.

A screenshot of the .NET Aspire dashboard Projects page.

Visual Studio tooling

Visual Studio provides additional features for working with .NET Aspire components and the App Host orchestrator project. These features are currently not available in Visual Studio Code or through the CLI.

Enable .NET Aspire preview support

In Visual Studio, you can enable preview support for .NET Aspire components and project templates. To enable preview support, select Tools > Options > and in the Search Settings textbox enter "aspire", then ensure that the Enable support for .NET Aspire is checked:

Visual Studio 2022, enable .NET Aspire preview support.

Likewise, you can disable preview support by unchecking the Enable .NET Aspire preview support option.

Add a component

You add .NET Aspire components to your app like any other NuGet package using Visual Studio. However, Visual Studio also provides UI options to add .NET Aspire components directly. You need to first enable preview support for .NET Aspire components in Visual Studio. For information see, Enable .NET Aspire preview support.

  1. In Visual Studio, right click on the project you want to add an .NET Aspire component to and select Add > .NET Aspire Component....

    The Visual Studio context menu displaying the Add .NET Aspire Component option.

  2. The package manager will open with search results pre-configured (populating filter criteria) for .NET Aspire components, allowing you to easily browse and select the desired component. The Include prerelease checkbox needs to be checked to see preview components.

    The Visual Studio context menu displaying the Add .NET Aspire options.

For more information on .NET Aspire components, see .NET Aspire components overview.

Add orchestration projects

You can add .NET Aspire orchestration projects to an existing app using the following steps:

  1. In Visual Studio, right click on an existing project and select Add > .NET Aspire Orchestrator Support...

    The Visual Studio context menu displaying the Add .NET Aspire Orchestrator Support option.

  2. A dialog window will open with a summary of the .AppHost and .ServiceDefaults projects that will be added to your solution.

    A screenshot showing the Visual Studio add .NET Aspire orchestration summary.

  3. Select OK and the following changes will be applied:

    • The .AppHost and .ServiceDefault orchestration projects will be added to your solution.
    • A call to builder.AddServiceDefaults will be added to the Program.cs file of your original project.
    • A reference to your original project will be added to the Program.cs file of the .AppHost project.

For more information on .NET Aspire orchestration, see .NET Aspire orchestration overview.

Enlist in orchestration

Visual Studio provides the option to Enlist in Aspire orchestration during the new project workflow. Select this option to have Visual Studio create .AppHost and .ServiceDefault projects alongside your selected project template.

A screenshot showing how to enlist in .NET Aspire orchestration.