microsoft/aspire · error · TimeoutException
Build for resource ' ' timed out after .
Error message
Build for resource '{resource.Name}' timed out after {BuildTimeout:c}. What it means
RunBuildAsync runs the MAUI build (dotnet build/run pipeline) with a per-resource build timeout (BuildTimeout). When the build process is killed because that timeout elapsed — not because the caller cancelled — the method kills the process and throws TimeoutException so the resource fails to start with a clear cause.
Solutions
- Increase the build timeout configuration (BuildTimeout) to accommodate cold restore/workload installs.
- Warm up the build by running dotnet build for the MAUI project once outside Aspire so subsequent queued builds are fast.
- Re-run after transient network/NuGet slowness; pre-restore packages (dotnet restore) to reduce build time.
- If cancellation is seen instead, check whether the caller token fired rather than the timeout CTS.
Example fix
// before .WithBuildTimeout(TimeSpan.FromMinutes(5)); // after .WithBuildTimeout(TimeSpan.FromMinutes(20)); // allow first-run workload restore
Defensive patterns
Strategy: retry
Validate before calling
// estimate: measure a cold build once var sw = Stopwatch.StartNew(); RunDotnetBuild(); sw.Stop(); if (sw.Elapsed > configuredTimeout) raiseTimeout();
Try / catch
try { await startMauiResourceAsync(); } catch (TimeoutException ex) when (ex.Message.Contains("timed out after")) { /* raise BuildTimeout and retry the build once */ } Prevention
- Set a generous BuildTimeout that covers cold restore and workload installs
- Warm the build cache (dotnet build) before running the AppHost
- Pre-restore NuGet packages and workloads on CI images
- Watch for slow networks during first-run package restore
When it happens
Trigger: The MAUI build (e.g. targeting iOS/Android/MacCatalyst workloads) takes longer than BuildTimeout; the timeout CancellationTokenSource fires during process.WaitForExitAsync while the caller token is still live (src/Aspire.Hosting.Maui/Lifecycle/MauiBuildQueueEventSubscriber.cs:235).
Common situations: First builds that restore workloads and NuGet packages (cold caches, slow networks); large MAUI solutions; slow CI machines or emulator-heavy targets; setting an aggressive custom BuildTimeout.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Build failed for resource
- Resource ' ' is missing MauiBuildInfoAnnotation. Cannot…
- The Aspire dashboard resource
- The MAUI OTLP dev tunnel configuration was not initialized…
- The MAUI OTLP endpoint could not be determined within
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/0ec05011b7673798.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Maui/Lifecycle/MauiBuildQueueEventSubscriber.cs:235
var token = timeoutCts.Token;
using var process = new Process { StartInfo = psi };
process.Start();
// Pipe stdout/stderr to the resource logger so output is visible in the dashboard.
var stdoutTask = PipeOutputAsync(process.StandardOutput, logger, LogLevel.Information, token);
var stderrTask = PipeOutputAsync(process.StandardError, logger, LogLevel.Warning, token);
try
{
await process.WaitForExitAsync(token).ConfigureAwait(false);
}
catch (OperationCanceledException) when (!cancellationToken.IsCancellationRequested)
{
// The timeout CTS fired, not the caller's token — this is a build timeout.
TryKillProcess(process, logger);
throw new TimeoutException(
$"Build for resource '{resource.Name}' timed out after {BuildTimeout:c}.");
}
catch (OperationCanceledException)
{
TryKillProcess(process, logger);
throw;
}
finally
{
// Always drain remaining output — even on cancellation the process was killed
// and the streams will reach EOF, so the tasks will complete promptly.
await Task.WhenAll(stdoutTask, stderrTask).ConfigureAwait(false);
}
if (process.ExitCode != 0)
{
throw new InvalidOperationException(
$"Build failed for resource '{resource.Name}' with exit code {process.ExitCode}.");View on GitHub (pinned to 25830f84bd)