Skip to content

CqrsMinimalApi: end-to-end production static-codegen example (no Roslyn)#4

Open
jeremydmiller wants to merge 2 commits into
mainfrom
sample-production-static-codegen
Open

CqrsMinimalApi: end-to-end production static-codegen example (no Roslyn)#4
jeremydmiller wants to merge 2 commits into
mainfrom
sample-production-static-codegen

Conversation

@jeremydmiller
Copy link
Copy Markdown
Member

Addresses wolverine#2900 — an end-to-end example of removing WolverineFx.RuntimeCompilation (Roslyn) from production builds.

Extends the RC pilot CqrsMinimalApi into a working, proven example of the Wolverine 6 production code-generation workflow: pre-generate code and run TypeLoadMode.Static in production without the WolverineFx.RuntimeCompilation package, while keeping runtime compilation for local dev.

Note on commits: this branch is based on the local chore/rc-conversion pilot, which isn't on origin, so this PR currently includes that pilot commit (Convert CqrsMinimalApi to RC matrix + .NET 10) in addition to my example commit. Squash or rebase onto the rc-conversion branch as you prefer.

What's added/changed (my commit)

  • Program.csCritterStackDefaults(x => { x.Production.GeneratedCodeMode = TypeLoadMode.Static; x.Production.AssertAllPreGeneratedTypesExist = true; }), and return await app.RunJasperFxCommands(args) so dotnet run -- codegen write works.
  • CqrsMinimalApi.csprojWolverineFx.RuntimeCompilation referenced only in <ItemGroup Condition="'$(Configuration)' == 'Debug'">; calls out the malformed-$(Configuration)-condition gotcha from #2900.
  • Internal/Generated/ — committed pre-generated code (codegen write; metadata-only, no DB needed).
  • Dockerfilecodegen writedotnet publish -c Release → Roslyn-free production image.
  • verify-production-build.sh — publishes Release and asserts no Wolverine.RuntimeCompilation / Microsoft.CodeAnalysis* / JasperFx.RuntimeCompiler.
  • Tests/ProductionStaticCodegenTests — Alba host with UseEnvironment("Production") proving the Static pre-generated path boots + serves.
  • README.md — workflow walkthrough + FAQ answering the #2900 questions.

Verification (local)

  • dotnet test Tests6/6 pass (5 existing endpoint tests + the new Production/Static boot test) against the repo's docker-compose Postgres.
  • ./verify-production-build.shPASS, Release publish confirmed Roslyn-free.

🤖 Generated with Claude Code

jeremydmiller and others added 2 commits May 21, 2026 11:37
- WolverineFx.Http / .Marten 5.30.0 -> 6.0.0-rc.2; net9.0 -> net10.0
- Add WolverineFx.RuntimeCompilation (Wolverine 6 core no longer ships
  Roslyn; Dynamic TypeLoadMode needs it for dev/test)
- Pin docker-compose postgres:latest -> postgres:17 (latest drifted to
  v18, whose data-dir layout breaks the /var/lib/postgresql/data mount)

Tests: 5/5 pass against Postgres 17 on :5433.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Demonstrates the Wolverine 6 production workflow requested in wolverine#2900: pre-generate code
and run TypeLoadMode.Static in production WITHOUT the WolverineFx.RuntimeCompilation (Roslyn)
package, while keeping runtime compilation for local Debug/dev.

- Program.cs: CritterStackDefaults Production -> TypeLoadMode.Static + AssertAllPreGeneratedTypesExist;
  RunJasperFxCommands(args) so `dotnet run -- codegen write` works.
- CqrsMinimalApi.csproj: WolverineFx.RuntimeCompilation referenced only in Debug (correctly-formed
  '$(Configuration)' condition — note the typo gotcha from #2900).
- Internal/Generated: committed pre-generated code (codegen write; metadata-only, no DB needed).
- Dockerfile: codegen write -> publish Release -> Roslyn-free production image.
- verify-production-build.sh: publishes Release and asserts no Wolverine.RuntimeCompilation /
  Microsoft.CodeAnalysis* / JasperFx.RuntimeCompiler in the output.
- Tests/ProductionStaticCodegenTests: boots with ASPNETCORE_ENVIRONMENT=Production and serves a
  request, proving the Static pre-generated path runs with no runtime compilation.
- README: workflow walkthrough + FAQ answering the #2900 questions.

Verified locally: 6/6 tests pass; Release publish confirmed Roslyn-free.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant