From fce9ed4e49a2d88e07eeba6e38d1593fd2400a4f Mon Sep 17 00:00:00 2001 From: afscrome Date: Sat, 21 Mar 2026 21:50:10 +0000 Subject: [PATCH] Don't swallow errors from `ExecutionConfigurationBuilder` when resource fails to start. --- src/Aspire.Hosting/Dcp/DcpExecutor.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Aspire.Hosting/Dcp/DcpExecutor.cs b/src/Aspire.Hosting/Dcp/DcpExecutor.cs index 1504bb97060..ed00196e6d2 100644 --- a/src/Aspire.Hosting/Dcp/DcpExecutor.cs +++ b/src/Aspire.Hosting/Dcp/DcpExecutor.cs @@ -14,6 +14,7 @@ using System.Net; using System.Net.Sockets; using System.Runtime.CompilerServices; +using System.Runtime.ExceptionServices; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using System.Text; @@ -1870,7 +1871,7 @@ private async Task CreateExecutableAsync(RenderedModelResource er, ILogger resou if (configuration.Exception is not null) { - throw new FailedToApplyEnvironmentException(); + ExceptionDispatchInfo.Throw(configuration.Exception); } // Invoke the debug configuration callback now that endpoints are allocated. @@ -2344,7 +2345,11 @@ private async Task CreateContainerAsync(RenderedModelResource cr, ILogger resour spec.Command = containerResource.Entrypoint; } - if (failedToApplyRunArgs || configuration.Exception is not null) + if (configuration.Exception is not null) + { + ExceptionDispatchInfo.Throw(configuration.Exception); + } + if (failedToApplyRunArgs) { throw new FailedToApplyEnvironmentException(); }