From 134f9c3eaf091b7a487b22105fe9565976dcb35d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Oct 2025 11:58:40 +0000 Subject: [PATCH 1/4] Initial plan From a2c264a0403c9a08dc71ad76bab2f4313f7a6cdb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Oct 2025 12:07:12 +0000 Subject: [PATCH 2/4] Add AddCSharpApp and CSharpAppResource documentation to app-host-overview.md Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com> --- docs/fundamentals/app-host-overview.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/fundamentals/app-host-overview.md b/docs/fundamentals/app-host-overview.md index 660e46470f..ff6ae52286 100644 --- a/docs/fundamentals/app-host-overview.md +++ b/docs/fundamentals/app-host-overview.md @@ -113,11 +113,12 @@ 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. | +| | | 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 method. To add a project to the app model, use the method: @@ -140,6 +141,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 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 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 method supports the same configuration options as , including replicas, environment variables, and resource dependencies. + +> [!NOTE] +> The 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: From c14c079979d3412778033712dfb1362ec3b5998b Mon Sep 17 00:00:00 2001 From: David Pine Date: Thu, 23 Oct 2025 07:16:58 -0500 Subject: [PATCH 3/4] Apply suggestions from code review --- docs/fundamentals/app-host-overview.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/fundamentals/app-host-overview.md b/docs/fundamentals/app-host-overview.md index ff6ae52286..c4aaee678c 100644 --- a/docs/fundamentals/app-host-overview.md +++ b/docs/fundamentals/app-host-overview.md @@ -113,12 +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. | -| | | A C# project or file-based app, for example, a .cs file, .csproj file, or project directory. | +| `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). Alternatively, you can add C# projects or file-based apps without a project reference using the method. + + +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: @@ -141,7 +145,7 @@ 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 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. +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 method: @@ -155,10 +159,10 @@ var inventoryService = builder.AddCSharpApp("inventoryservice", @"..\InventorySe var catalogService = builder.AddCSharpApp("catalogservice", @"..\CatalogService"); ``` -The method supports the same configuration options as , including replicas, environment variables, and resource dependencies. +The `AddCSharpApp` method supports the same configuration options as , including replicas, environment variables, and resource dependencies. > [!NOTE] -> The 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. +> 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 From cd62773b47411506a0832d06db363d1bb02d0b16 Mon Sep 17 00:00:00 2001 From: David Pine Date: Thu, 23 Oct 2025 07:21:58 -0500 Subject: [PATCH 4/4] Update docs/fundamentals/app-host-overview.md --- docs/fundamentals/app-host-overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/fundamentals/app-host-overview.md b/docs/fundamentals/app-host-overview.md index c4aaee678c..88d558d762 100644 --- a/docs/fundamentals/app-host-overview.md +++ b/docs/fundamentals/app-host-overview.md @@ -147,7 +147,7 @@ The preceding code adds three replicas of the "apiservice" project resource to t 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 method: +To add a C# app to the app model, use the `AddCSharpApp` method: ```csharp var builder = DistributedApplication.CreateBuilder(args);