Skip to content

Build a template project for each project shape when the image is built (no run-time change) - #331

Open
iHiD wants to merge 1 commit into
mainfrom
csharp-project-shapes
Open

iHiD wants to merge 1 commit into
mainfrom
csharp-project-shapes

Conversation

@iHiD

@iHiD iHiD commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Hello 🙂 I'm working with Claude to try and get our tooling faster.

This PR is the second of three that together make this project around 5x faster. On its own it doesn't change the speed. I've run it in production to benchmark things in the real world against the most recent few hundred solutions, so I'm confident that it works robustly. However, I've not written the code. I have tried my hardest to get Claude to write sensible messages and comments that explains stuff, but I'd ask for your patience in the fact I'm sending AI code to you. Everything below here is from your friendly neighbourhood LLM...


This is the second of three PRs. Merge them in order: #330, then this one (#331), then #332.

What changed

  • This PR builds a template project for each project shape when the image is built. The new shapes/ folder holds one template project file for each distinct .csproj the track has used since it switched to xUnit v3 (16 at the moment). These templates are called shapes. bin/generate-shapes.py writes them from the track repo's history.
  • bin/build-shapes.sh builds each shape with the .NET SDK. It saves the compiler arguments, the source files generated by the SDK and packages, and the resolved dependencies. The script also precompiles the dependencies with ReadyToRun, so the test executable will spend less time in the JIT compiler. If a shape fails to build, the script removes it.
  • The runner has a new --prepare-shape option, which the script calls after each build. It reduces the shape's .csproj to its properties, Using items and package references (see ProjectShape.cs), and saves that as the shape's key. The next PR matches each solution's project file against these keys.
  • This PR changes nothing at run time. The runner doesn't use the shapes yet. The next PR (Compile xUnit v3 solutions in-process with Roslyn (~5x faster with the whole stack) #332) uses them to compile solutions without MSBuild.
  • The image grows from 1.24 GB to 1.54 GB. Identical files across the shapes are hard-linked to keep this down.

This has been tested in production. It doesn't change the median run, which stays at 6.2s.

🤖 Generated with Claude Code

The new shapes/ folder holds one template project file for each
distinct xUnit v3 .csproj used by the track since it switched to
xUnit v3. bin/generate-shapes.py writes them from the track's history.

When the image is built, bin/build-shapes.sh builds each template with
the .NET SDK. It keeps the compiler arguments, the source files
generated by the SDK and packages, and the dependencies precompiled
with ReadyToRun. Identical files across the shapes are hard-linked.
The runner's new --prepare-shape option writes each shape's key (see
ProjectShape.cs).

Nothing uses the shapes at run time yet, so the runner behaves exactly
as before. A fast path in a later change will use them.

Co-authored-by: iHiD <286476+iHiD@users.noreply.github.com>

Co-Authored-By: Claude Opus 5.5 <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