microsoft / microsoft/aspire

TypeScript AppHost runs project resource with Release configuration during local development

Open
#16,444 1 comment 0 reactions 0 assignees View on GitHub
area-polyglot javascript
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

TypeScript AppHost launches .NET project resources with `--configuration Release` during `aspire start`.

When using a TypeScript AppHost (`apphost.ts`) with Aspire CLI 13.2.3, a .NET project resource added with `builder.addProject(...)` is built as `Release` during local development.

This is surprising because `aspire start` / `aspire run` is a development workflow, and direct `dotnet run` for the same project uses `Debug` by default. The selected launch profile also sets `ASPNETCORE_ENVIRONMENT=Development`.

As the ASP.NET service is built in Release mode, we are missing some debugging information available only in Debug builds of our service.

### Expected Behavior

Running a .NET project resource in TypeScript based app host will build it in Debug mode by default.

A TypeScript AppHost should not cause service projects to inherit `Release` from Aspire's prebuilt AppHost/runtime infrastructure.

### Steps To Reproduce

[aspire-release-config-repro.zip](https://github.com/user-attachments/files/27066295/aspire-release-config-repro.zip)

```ts
// apphost.ts
import { createBuilder } from './.modules/aspire.js';

const builder = await createBuilder();

await builder
.addProject("api", "./api/Api.csproj", "http")
.withExternalHttpEndpoints();

await builder.build().run();
```

```cs
// Program.cs
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

var buildConfiguration =
#if DEBUG
"Debug";
#else
"Release";
#endif

Console.WriteLine($"Build configuration: {buildConfiguration}");

app.MapGet("/", () => new { buildConfiguration });

app.Run();
```

```xml


net10.0
enable
enable

```

### Exceptions (if any)

None.

### Aspire doctor output

```
Aspire Environment Check
========================

Container Runtime
⚠ Docker Engine detected (version 29.4.1). Aspire's container tunnel is
required to allow containers to reach applications running on the host
Set environment variable: ASPIRE_ENABLE_CONTAINER_TUNNEL=true
See: https://aka.ms/aspire-prerequisites#docker-engine

Environment
✔ WSL2 environment detected
Details:
If you experience container connectivity issues, ensure Docker
Desktop WSL integration is enabled.
⚠ HTTPS development certificate is only partially trusted
Set SSL_CERT_DIR in your shell profile: export
SSL_CERT_DIR="$SSL_CERT_DIR:/home/jozef/.aspnet/dev-certs/trust"
See: https://aka.ms/aspire-prerequisites#dev-certs
Details:
The certificate is in the trusted store, but SSL_CERT_DIR is not
configured to include '/home/jozef/.aspnet/dev-certs/trust'. Some
applications may not trust the certificate. 'aspire run' will
configure this automatically.

Summary: 1 passed, 2 warnings, 0 failed
```

### Anything else?

## Environment

- Aspire CLI: `13.2.3+0838645cc4f7fc27e46200ac14cbe5c751637593`
- Aspire SDK: `13.2.3`
- `Aspire.Hosting.JavaScript`: `13.2.3`
- `Aspire.Hosting.SqlServer`: `13.2.3`
- .NET SDK: `10.0.203`
- Node.js: `v24.14.0`
- npm: `11.11.1`
- OS: WSL2 Ubuntu on Linux kernel `6.6.87.2-microsoft-standard-WSL2`

## Suspected cause

In Aspire 13.2.3, DCP adds the AppHost assembly configuration to project resource arguments:

```csharp
if (!string.IsNullOrEmpty(_distributedApplicationOptions.Configuration))
{
projectArgs.AddRange(new[] { "--configuration", _distributedApplicationOptions.Configuration });
}
```

Source:

That value is resolved from the AppHost assembly's `AssemblyConfigurationAttribute`:

```csharp
private string? ResolveConfiguration()
{
return Assembly?.GetCustomAttribute()?.Configuration;
}
```

Source:

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.