Skip to content

.NET extraction: shared NuGet locks, failing placeholder inputs, first-error summaries, host-only dotnet-di, workload skips - #416

Open
agorischek wants to merge 3 commits into
mainfrom
agorischek-sturdy-goggles
Open

agorischek wants to merge 3 commits into
mainfrom
agorischek-sturdy-goggles

Conversation

@agorischek

@agorischek agorischek commented Dec 5, 2026 •

Copy link
Copy Markdown
Collaborator

What changed

Fixes five .NET extraction problems that setup trials on large .NET repositories turned up.

  1. NuGet cache race (the major one). The runner gives every extraction a private TMPDIR, and the .NET extractors give each a private DOTNET_CLI_HOME. NuGet keeps the cross-process locks that make concurrent restores take turns extracting a package in NUGET_SCRATCH/lock. That folder defaults to $TMPDIR/NuGetScratch<user>, or on newer Linux NuGet to the NuGet home under DOTNET_CLI_HOME, and both are private per extraction. So parallel extractions sharing one packages folder never saw each other's locks: one deleted another's half-written package file (Could not find file '<packages>/<id>/<version>/gubdyv4y.32d'). Dotnet::new now sets NUGET_SCRATCH to one folder for all of the user's extractions, .nuget/projections-scratch under the NuGet home, unless the definition grants NUGET_SCRATCH. This covers dotnet-di, dotnet-public-api, efcore-schema and nuget-dependencies. The dotnet-support README wrongly said concurrent restores were safe; it now explains this.
  2. Placeholder inputs pass silently. A sweep cell now fails when a declared input is missing at both revisions and in the working tree (for example a template's placeholder src/App/App.csproj). It says: "Declared input src/App/App.csproj doesn't exist in the working tree or at either revision. Fix the projection's inputs". An input added after older revisions still reads as absent there, as before. Separately, explore proposes efcore-schema once per project that holds a DbContext (the nearest enclosing .csproj), with inputs.project set, instead of the template's placeholder.
  3. Sweep summary truncates the cause. failure_reason used stderr's last line. It now takes the first error line (error CS…:, … : error NU1101:, …Exception:), skipping one that only introduces the next. Failing that, it uses the extractor's own report when that says more than how the process exited, then the last line. The lines under the summary show the details after the reason, or what led up to it when it's last. The .NET extractors also lead a missing SDK with what global.json requests: "A compatible .NET SDK was not found: the repository's global.json requests SDK 10.0.0…". dotnet's own wording varies by command; dotnet nuget puts it under "The command could not be loaded, possibly because:". The reason logic moved to sweep/reason.rs to keep sweep/mod.rs under the complexity limit.
  4. explore proposes dotnet-di for fuzz harnesses. dotnet-di is proposed only when the Program.cs/Startup.cs builds a host or service collection (HostBuilder, Host.Create, WebApplication, WebHost, ServiceCollection, ConfigureServices, UseStartup), or its project uses the Web or Worker SDK or references Microsoft.Extensions.Hosting or Microsoft.AspNetCore. Test, fuzz and benchmark projects (by path or name words) are never proposed.
  5. nuget-dependencies and MAUI. A project whose restore fails with NETSDK1147 (missing workload) or NETSDK1139 (unrecognized platform) is skipped. A limitation names it and gives the workload message without checkout paths. The extraction fails only if every project needs a missing workload.

Out of scope, unchanged: default timeouts, how dotnet-di invokes Main, explore candidate ID naming, and nuget-dependencies grouping.

Evidence

  • Race reproduced and fixed, by direct experiment (.NET SDK 11.0.100). I ran 6 concurrent dotnet restores × 4 rounds, each with its own TMPDIR and DOTNET_CLI_HOME, sharing a fresh NUGET_PACKAGES. Without a shared scratch, 24/24 failed with the same signature (Could not find file '…/microsoft.aspnetcore.app.ref/8.0.34/xm3aqsfz.fgm', Directory not empty). With a shared NUGET_SCRATCH, 0/24 failed.

  • End to end with a debug CLI on a synthetic repository (web API, worker, MAUI net11.0-android project, SharpFuzz harness, DbContext library; 6 commits):

    • explore --list proposed dotnet-di-api and dotnet-di-worker but not the fuzz harness, and efcore-schema-data with src/Data/Data.csproj.
    • explore --sweep --trust --concurrency 4 with a fresh shared packages folder: all nuget-dependencies cells succeeded, with the MAUI project skipped in every revision, using the real NETSDK1147 output.
    • A placeholder efcore-schema definition failed on 5 of 5 changes with the message above.
    • With global.json requesting 10.0.0, the summary read A compatible .NET SDK was not found: the repository's global.json requests SDK 10.0.0…, where it used to show https://aka.ms/dotnet/sdk-not-found.
  • cargo test -p projections-extractor-dotnet-support --lib: 9 passed (new: shared scratch, missing SDK)

  • cargo test -p projections-extractor-nuget-dependencies: passed (new: workload skip)

  • cargo test -p projections-cli --lib -- sweep:: explore::: 58 passed (new: first-error reason, absent inputs, host-only dotnet-di, efcore project)

  • cargo test -p projections-cli --test authoring -- adopting_writes_definitions_and_bookmarks explore: 6 passed. The adopt test now gives its DbContext a project, so explore still proposes efcore-schema there.

  • Review follow-ups (7e8265e):

    • PascalCase harness names (ApiTests, HTTPFuzz) are detected.
    • A sweep cell keeps the reason chosen from the whole stderr, so a first error before the kept tail still wins.
    • Without a NuGet home, a granted NUGET_PACKAGES folder holds the shared scratch folder.
    • cargo test -p projections-cli --lib -- sweep:: explore::: 59 passed. cargo test -p projections-extractor-dotnet-support --lib: 9 passed.
  • cargo clippy -p projections-cli -p projections-extractor-dotnet-support -p projections-extractor-nuget-dependencies --all-targets -- -D warnings: clean

  • npm run tools -- check --fast: pass

  • Not run locally: the opt-in native .NET extractor suites, other platforms, and the full tools check/tools test. They're left to CI because of sandbox disk limits.

  • Documentation that this change affects is updated, and generated reference
    pages are regenerated (npm run docs:generate).

  • Fixes include a regression test.

  • A changelog fragment at changelog.d/<this PR's number>.md describes what
    users will notice, or the PR has the no changelog label (see
    changelog.d/README.md).

  • No credentials, private source or machine-specific paths are included.

agorischek and others added 2 commits December 5, 2026 03:17
…rror summaries, host-only dotnet-di, workload skips

- Every .NET extraction shares one NUGET_SCRATCH under the NuGet home, so
  concurrent restores into one packages folder see each other's locks.
- A sweep fails a change whose declared input exists at neither revision nor
  in the working tree; explore proposes efcore-schema for the DbContext's project.
- Sweep summaries give the first error line, and .NET extractors lead a
  missing SDK with the version global.json requests.
- explore proposes dotnet-di only for programs that build a host, never for
  test, fuzz or benchmark projects.
- nuget-dependencies skips projects needing a missing workload with a limitation.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved issues leave shared NuGet caches vulnerable to restore races, can misreport the first build error, and allow PascalCase test projects to be proposed for dotnet-di.

3 open issues
What changed in this PR

Improves .NET extraction reliability, project discovery, and failure reporting across the extractors and CLI.

Changes:

  • Adds shared NuGet locking and skips projects requiring unavailable workloads.
  • Refines host detection and proposes EF Core extraction for actual projects.
  • Rejects missing placeholder inputs and improves SDK and sweep error summaries.
File Description
packages/​extractors/​nuget-dependencies/​tests/​restore.rs Tests workload skips and all-skipped failures.
packages/​extractors/​nuget-dependencies/​src/​lib.rs Skips workload-dependent projects with limitations.
packages/​extractors/​nuget-dependencies/​README.md Documents workload handling.
packages/​extractors/​dotnet-support/​src/​toolchain.rs Adds shared scratch selection and SDK diagnostics.
packages/​extractors/​dotnet-support/​src/​tests.rs Tests scratch configuration and SDK errors.
packages/​extractors/​dotnet-support/​README.md Explains shared NuGet locking.
packages/​cli/​tests/​authoring.rs Gives the EF Core fixture a project.
packages/​cli/​src/​sweep/​tests.rs Tests failure summaries and missing inputs.
packages/​cli/​src/​sweep/​run.rs Fails cells with nonexistent declared inputs.
packages/​cli/​src/​sweep/​reason.rs Extracts failure reasons and diagnostic context.
packages/​cli/​src/​sweep/​mod.rs Integrates the new summary logic.
packages/​cli/​src/​explore/​dotnet.rs Refines host detection and EF Core proposals.
packages/​cli/​src/​explore.rs Passes repository context to .NET discovery.
changelog.d/​416.md Records user-visible fixes.

Review effort: Balanced

Comment thread packages/cli/src/explore/dotnet.rs Resolved
Comment thread packages/cli/src/sweep/reason.rs Resolved
…atch beside an explicit packages folder

- explore splits PascalCase names into words, so ApiTests and HTTPFuzz are
  harnesses while Contest isn't.
- A failed sweep cell keeps the reason chosen from the whole stderr, so a
  first error before the kept tail still names the failure; a timeout stays
  the reason.
- Without a NuGet home, a granted NUGET_PACKAGES folder holds the shared
  NuGet scratch folder, so concurrent restores into it still share locks.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

2 participants