9/17/2025 Admin

Using Visual Studio Code with Aspire and Blazor


You can use Blazor with Aspire and Visual Studio Code.

 

Install Visual Studio Code

image_thumb[7]

One of the advantages of using Visual Studio Code rather than Visual Studio, is that Visual Studio Code is lightweight and runs on more platforms.

Go to: https://code.visualstudio.com/download to download and install Visual Studio Code for your OS.

 

image_thumb[8]

Launch VS Code after installation.

 

Install the C# Dev Kit Extension

image_thumb[22]

In Visual Studio Code, go to View > Extensions (or press Ctrl+Shift+X).

Search for C# Dev Kit and click Install Pre-Release Version.

After installation has completed, close and re-open Visual Studio Code.

This extension provides rich C# editing, debugging, and project management features.

 

Install the .NET Aspire Project Templates

image_thumb[10]

Open the integrated terminal in Visual Studio Code (View > Terminal or Ctrl+’).

Run the following command: dotnet new install Aspire.ProjectTemplates

After installation has completed, close and re-open Visual Studio Code.


Create the Aspire App Host Project

image_thumb[11]

Select File > New File.

 

image_thumb[23]

Select .NET: New Project.

 

image_thumb[13]

Select .NET Aspire App Host.

 

image_thumb[25]

Create a folder and select it.

 

image_thumb[15]

Give the project the name AspireVibeCodingVSCode.

 

image_thumb[16]

Select .sln.

 

image_thumb[17]

Select Show all template options.

 

image_thumb[18]

Configure the options so they match the settings in the image above.

Select Create project.

 

image_thumb[26]

When the dialog appears select Yes, I trust the authors.

 

Switch to Explorer View

image_thumb[21]

The C# Dev Kit provides the Solution Explorer that allows you to more easily manage your C# project.

Expand the Solution Explorer.

(if you don’t see it, close and re-open your Visual Studio Code)

 

Create the Blazor Web App Project

image_thumb[27]

Select New Project.

 

image_thumb[29]

Search for and select Blazor Web App as the template.

 

image_thumb[30]

Name it BlazorWebApp and press Enter.

 

image_thumb[31]

Select the Default directory.

 

image_thumb[35]

Select Show all template options.

 

image_thumb[36]

Configure the options so they match the settings in the image above.

Select Create project.

 

Link the Projects

image_thumb[37]

In the Solution Explorer, right-click on the AppHost project (AspireVibeCodingVSCode).

Select Add Project Reference.

image_thumb[38]

Select BlazorWebApp and press Enter.

 

Update AppHost

image_thumb[39]

Open AppHost.cs in the AppHost project and add:

builder.AddProject<Projects.BlazorWebApp>("BlazorWebApp");

Select File > Save to save the changes.

 

Debug and Run

image_thumb[40]

Press F5 or go to Run > Start Debugging.

Select C#.

 

image_thumb[41]

Select C#: Launch Startup Project.

 

image_thumb[42]

Select AspireVibeCodingVSCode.

 

image_thumb[46]

Your browser should open with the running Blazor app hosted by the Aspire App Host.

 

Links

Aspire Overview

Visual Studio Code

An unhandled error has occurred. Reload 🗙