.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 Visual Studio, Visual Studio Code, and CLI workflows. In the sections ahead, you 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, Visual Studio Code, or the .NET CLI
- Install .NET Aspire integrations
- Work with the .NET Aspire dashboard
Install .NET Aspire
To work with .NET Aspire, you need the following installed locally:
- .NET 8.0 or .NET 9.0.
- .NET Aspire SDK
- An OCI compliant container runtime, such as:
- Docker Desktop or Podman. For more information, see Container runtime.
- An Integrated Developer Environment (IDE) or code editor, such as:
- Visual Studio 2022 version 17.9 or higher (Optional)
- Visual Studio Code (Optional)
- C# Dev Kit: Extension (Optional)
- JetBrains Rider with .NET Aspire plugin (Optional)
Visual Studio 2022 17.9 or higher includes the latest .NET Aspire SDK by default when you install the Web & Cloud workload.
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.
To ensure that you install the latest version of the .NET Aspire SDK, ...
Container runtime
.NET Aspire projects are designed to run in containers. You can use either Docker Desktop or Podman as your container runtime. Docker Desktop is the most common container runtime. Podman is an open-source daemonless alternative to Docker, that can build and run Open Container Initiative (OCI) containers. If your host environment has both Docker and Podman installed, .NET Aspire defaults to using Docker. You can instruct .NET Aspire to use Podman instead, by setting the DOTNET_ASPIRE_CONTAINER_RUNTIME
environment variable to podman
:
export DOTNET_ASPIRE_CONTAINER_RUNTIME=podman
For more information, see Install Podman on Linux.
.NET Aspire templates
.NET Aspire provides a set of solution and project templates. These templates are available in your favorite .NET developer integrated environment. You can use these templates to create full .NET Aspire solutions, or add individual projects to existing .NET Aspire solutions. For more information, see .NET Aspire templates.
.NET Aspire dashboard
.NET Aspire templates that expose the app host project also include a useful developer dashboard that's 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 and Visual Studio Code launch 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 explore in the following sections.
The .NET Aspire dashboard is also available in a standalone mode. For more information, see Standalone .NET Aspire dashboard.
Visual Studio tooling
Visual Studio provides additional features for working with .NET Aspire integrations and the App Host orchestrator project. Not all of these features are currently available in Visual Studio Code or through the CLI.
Add an integration package
You add .NET Aspire integrations to your app like any other NuGet package using Visual Studio. However, Visual Studio also provides UI options to add .NET Aspire integrations directly.
In Visual Studio, right select on the project you want to add an .NET Aspire integration to and select Add > .NET Aspire package....
The package manager opens with search results preconfigured (populating filter criteria) for .NET Aspire integrations, allowing you to easily browse and select the desired integration.
For more information on .NET Aspire integrations, see .NET Aspire integrations overview.
Add hosting packages
.NET Aspire hosting packages are used to configure various resources and dependencies an app may depend on or consume. Hosting packages are differentiated from other integration packages in that they're added to the *.AppHost project. To add a hosting package to your app, follow these steps:
In Visual Studio, right select on the *.AppHost project and select Add > .NET Aspire package....
The package manager opens with search results preconfigured (populating filter criteria) for .NET Aspire hosting packages, allowing you to easily browse and select the desired package.
Add orchestration projects
You can add .NET Aspire orchestration projects to an existing app using the following steps:
In Visual Studio, right select on an existing project and select Add > .NET Aspire Orchestrator Support...
A dialog window opens with a summary of the *.AppHost and *.ServiceDefaults projects that are added to your solution.
Select OK and the following changes are applied:
- The *.AppHost and *.ServiceDefaults orchestration projects are 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 *.ServiceDefaults projects alongside your selected project template.
Create test project
When you're using Visual Studio, and you select the .NET Aspire Start Application template, you have the option to include a test project. This test project is an xUnit project that includes a sample test that you can use as a starting point for your tests.
For more information, see Write your first .NET Aspire test.
Visual Studio Code tooling
You can use Visual Studio Code, with the C# Dev Kit extension, to create and develop .NET Aspire projects. To create a new .NET Aspire project in Visual Studio Code, select the Create .NET Project button in the Explorer view, then select one of the .NET Aspire templates:
Once you create a new .NET Aspire project, you run and debug the app, stepping through breakpoints, and inspecting variables using the Visual Studio Code debugger: