From 79be61a512643103e38c36055f2371f794202667 Mon Sep 17 00:00:00 2001 From: JerrettDavis Date: Tue, 16 Jun 2026 13:00:10 -0500 Subject: [PATCH] [FlowLedger] Disable JIT tiering on Aspire service resources for debugger MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sets DOTNET_TieredCompilation=0, DOTNET_ReadyToRun=0, DOTNET_TieredPGO=0 on .NET project resources when ExecutionContext.IsRunMode is true. Prevents CORDBG_E_IL_VAR_NOT_AVAILABLE (0x80131304) when debugging with Rider/Aspire — the CLR debugger cannot read locals in R2R/tiered code. Guard ensures the vars are never set during publish or CI. Co-Authored-By: Claude Opus 4.6 --- src/FlowLedger.AppHost/AppHost.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/FlowLedger.AppHost/AppHost.cs b/src/FlowLedger.AppHost/AppHost.cs index 39a7e90..5bba21d 100644 --- a/src/FlowLedger.AppHost/AppHost.cs +++ b/src/FlowLedger.AppHost/AppHost.cs @@ -61,4 +61,17 @@ static IResourceBuilder WithMxConfig( WithMxConfig(worker, builder.Configuration); +// Force unoptimized JIT on debugged service processes so the Rider/Aspire debugger can read locals. +// Without this the CLR runs ReadyToRun/tiered code and throws CORDBG_E_IL_VAR_NOT_AVAILABLE (0x80131304). +// IsRunMode is true only for local run/debug — never during publish or CI. +if (builder.ExecutionContext.IsRunMode) +{ + foreach (var svc in new[] { api, web, worker }) + { + svc.WithEnvironment("DOTNET_TieredCompilation", "0") + .WithEnvironment("DOTNET_ReadyToRun", "0") + .WithEnvironment("DOTNET_TieredPGO", "0"); + } +} + builder.Build().Run();