diff --git a/docs/fundamentals/app-host-overview.md b/docs/fundamentals/app-host-overview.md index 660e46470f..88d558d762 100644 --- a/docs/fundamentals/app-host-overview.md +++ b/docs/fundamentals/app-host-overview.md @@ -113,11 +113,16 @@ Aspire projects are made up of a set of resources. The primary base resource typ | Method | Resource type | Description | |--|--|--| | | | A .NET project, for example, an ASP.NET Core web app. | +| `AddCSharpApp` | `CSharpAppResource` | A C# project or file-based app, for example, a _*.cs_ file, _*.csproj_ file, or project directory. | | | | A container image, such as a Docker image. | | | | An executable file, such as a [Node.js app](../get-started/build-aspire-apps-with-nodejs.md). | | | | A parameter resource that can be used to [express external parameters](external-parameters.md). | -Project resources represent .NET projects that are part of the app model. When you add a project reference to the AppHost project, the Aspire SDK generates a type in the `Projects` namespace for each referenced project. For more information, see [Aspire SDK: Project references](dotnet-aspire-sdk.md#project-references). + + +Project resources represent .NET projects that are part of the app model. When you add a project reference to the AppHost project, the Aspire SDK generates a type in the `Projects` namespace for each referenced project. For more information, see [Aspire SDK: Project references](dotnet-aspire-sdk.md#project-references). Alternatively, you can add C# projects or file-based apps without a project reference using the `AddCSharpApp` method. To add a project to the app model, use the method: @@ -140,6 +145,25 @@ var apiservice = builder.AddProject("apiservice") The preceding code adds three replicas of the "apiservice" project resource to the app model. For more information, see [Aspire dashboard: Resource replicas](dashboard/explore.md#resource-replicas). +C# app resources represent C# projects or file-based apps that are part of the app model. Unlike , which requires a project reference, the `AddCSharpApp` method can add C# projects or file-based apps using a path to a _*.cs_ file, _*.csproj_ file, or project directory. This is useful for adding file-based apps introduced in .NET 10 or for including projects without adding a project reference to the AppHost. + +To add a C# app to the app model, use the `AddCSharpApp` method: + +```csharp +var builder = DistributedApplication.CreateBuilder(args); + +// Adds a file-based C# app "inventoryservice" from a .cs file. +var inventoryService = builder.AddCSharpApp("inventoryservice", @"..\InventoryService.cs"); + +// Adds a C# project "catalogservice" from a project directory. +var catalogService = builder.AddCSharpApp("catalogservice", @"..\CatalogService"); +``` + +The `AddCSharpApp` method supports the same configuration options as , including replicas, environment variables, and resource dependencies. + +> [!NOTE] +> The `AddCSharpApp` method is marked as experimental and requires .NET 10 SDK for file-based C# app support. For more information on file-based apps, see the [What's new in Aspire 9.5](../whats-new/dotnet-aspire-9.5.md#file-based-apphost-support-preview) documentation. + ## Reference resources A reference represents a dependency between resources. For example, you can probably imagine a scenario where a web frontend depends on a Redis cache. Consider the following example AppHost `Program` C# code: