Aspire

Legacy project resources

.NET logo

This page is a reference for AppHosts that still use the legacy ProjectResource model through AddProject, AddCSharpApp, or TypeScript addProject.

A TypeScript AppHost passes the path to the .csproj file:

apphost.mts
import { createBuilder } from './.aspire/modules/aspire.mjs';
const builder = await createBuilder();
const api = await builder.addProject("api", "../ApiService/ApiService.csproj");
await builder.build().run();

Legacy project resources support the same resource APIs as other Aspire resources, such as WithReference, WaitFor, endpoints, and environment variables. For guidance that applies to all .NET project resources, see:

Legacy APIs take the launch profile as a method argument rather than an options object:

apphost.mts
await builder.addProject("inventoryservice", "../InventoryService/InventoryService.csproj", {
launchProfileOrOptions: "https",
});

AddDotnetProject exposes the same choices through launchProfileName, excludeLaunchProfile, and excludeKestrelEndpoints options. See Configure options.

To rename a generated Projects.* type, for example when two projects have the same name, set AspireProjectMetadataTypeName on the ProjectReference. AddDotnetProject takes a path, so it doesn’t use generated types or this metadata.

For the full set of ProjectReference metadata, see Generated project metadata.