.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:
- .NET 8.0
- .NET Aspire workload
- Docker Desktop
- Integrated Developer Environment (IDE) or code editor, such as:
- Visual Studio 2022 Preview version 17.10 or higher (Optional)
- Visual Studio Code (Optional)
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 4 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.
Open the Visual Studio Installer.
Select Modify next to Visual Studio 2022 Preview.
Select the ASP.NET and web development workload.
On the Installation details panel, select .NET Aspire SDK (Preview).
Select Modify to install the .NET Aspire component.
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 updateTo install the .NET Aspire workload from the .NET CLI, use the dotnet workload install command:
dotnet workload install aspireTo 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 four 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.
.NET Aspire App Host: A standalone .AppHost project that can be used to orchestrate and manage the different projects and services of your app.
.NET Aspire Service Defaults: A standalone .ServiceDefaults project that can be used to manage configurations that are reused across the projects in your solution related to resilience, service discovery, and telemetry.
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.
.NET Aspire dashboard
.NET Aspire templates that expose the app host project 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, or hold Ctrl and select the link (if your terminal supports hyperlinks).
The left navigation provides links to the different parts of the dashboard, each of which you'll explore in the following sections.
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.
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.
In Visual Studio, right click on the project you want to add an .NET Aspire component to and select Add > .NET Aspire Component....
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.
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:
In Visual Studio, right click on an existing project and select Add > .NET Aspire Orchestrator Support...
A dialog window will open with a summary of the .AppHost and .ServiceDefaults projects that will be added to your solution.
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.AddServiceDefaultswill 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.
.NET Aspire
Feedback
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see: https://aka.ms/ContentUserFeedback.
Submit and view feedback for