Expose `NoLaunchProfile` in `DistributedApplicationOptions` to disable using launchProfile.json permanently
- 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
### Is your feature request related to a problem? Please describe the problem.
We use Aspire primarily for integration tests and for running a local environment. Several of our test projects start multiple containers and local projects. When launch profiles are applied, local projects bind to fixed ports, which causes port clashes and cross-tenant bleed when multiple test projects run in parallel.
Sample fixture for XUnit
```csharp
public sealed class ApplicationHostFixture()
: DistributedApplicationFactory(
typeof(MyCompany_AppHost),
[
$"--TENANT={Tenant}",
]
),
IAsyncLifetime
{}
[CollectionDefinition("Integration Tests Collection")]
public abstract class ApplicationHostCollection : ICollectionFixture;
```
Expected behavior:
ports for local projects should be randomized (ephemeral) per test run/project to avoid interference.
### Describe the solution you'd like
First-class support to run without launch profiles
1. Global opt-out of launch profiles
Via environment variable, e.g. `ASPIRE_DISABLE_LAUNCH_PROFILES=true`
Or via DistributedApplicationOptions, e.g.:
```csharp
var builder = DistributedApplication.CreateBuilder(new DistributedApplicationOptions
{
UseLaunchProfiles = false
});
```
2. Per-project opt-out
A fluent API to disable the launch profile for a specific project:
```csharp
_ = builder
.AddProject("mock-grpc")
.NoLaunchProfile()
.WithHttpEndpoint(port: null, targetPort: 5000, name: "http")
.WithHttp2Endpoint()
.AsHttp2Service();
```
3. Ephemeral port assignment
When `.WithHttpEndpoint(port: null, ...)` is used (globally or per project), Aspire should assign a free ephemeral port at runtime and propagate that binding to dependent services and generated connection strings/URIs.
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.