Isolate nested SourceGenerator build/pack outputs in package reference tests#1096
Closed
christianhelle with Copilot wants to merge 2 commits into
Closed
Isolate nested SourceGenerator build/pack outputs in package reference tests#1096christianhelle with Copilot wants to merge 2 commits into
christianhelle with Copilot wants to merge 2 commits into
Conversation
Copilot
AI
changed the title
[WIP] Fix CI job failure in SourceGenerator tests
Isolate nested SourceGenerator build/pack outputs in package reference tests
May 29, 2026
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1096 +/- ##
==========================================
- Coverage 95.90% 95.29% -0.62%
==========================================
Files 27 27
Lines 2590 2997 +407
==========================================
+ Hits 2484 2856 +372
- Misses 36 45 +9
- Partials 70 96 +26
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the source-generator package reference tests to avoid nested build/pack operations writing to shared project output paths, reducing CI file-lock contention around package generation.
Changes:
- Creates per-test build, intermediate, and package output directories under the test workspace.
- Passes isolated output/intermediate paths to nested
dotnet buildanddotnet pack --no-build.
| $"-p:PackageOutputPath={packageOutputPath}"); | ||
| $"-p:PackageOutputPath={packageOutputPath}", | ||
| $"-p:OutputPath={buildOutputPath}{Path.DirectorySeparatorChar}", | ||
| $"-p:IntermediateOutputPath={intermediateOutputPath}{Path.DirectorySeparatorChar}"); |
| $"-p:PackageVersion={version}"); | ||
| $"-p:PackageVersion={version}", | ||
| $"-p:OutputPath={buildOutputPath}{Path.DirectorySeparatorChar}", | ||
| $"-p:IntermediateOutputPath={intermediateOutputPath}{Path.DirectorySeparatorChar}"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description:
CI was intermittently failing in
SourceGeneratorPackageReferenceTestswhen nesteddotnet build/dotnet packtouched sharedsrc/Refitter.SourceGenerator/binandobjpaths, causingGenerateDepsFilefile-lock contention onRefitter.SourceGenerator.deps.json.What changed
SourceGeneratorPackageReferenceTeststo create per-test workspace artifact paths:buildforOutputPathobjforIntermediateOutputPathpackagesforPackageOutputPathdotnet buildanddotnet pack --no-build, so pack consumes the same build artifacts without writing to shared repo outputs.Scope
src/Refitter.SourceGenerator.Tests/SourceGeneratorPackageReferenceTests.csExample OpenAPI Specifications:
Not applicable for this test infrastructure/packaging isolation change.
Example generated Refit interface
Original prompt
Apply the fix for the failing CI job on pull request #1095 in repository
christianhelle/refitter.Context:
GenerateDepsFilethrowingSystem.IO.IOExceptionwhile buildingsrc/Refitter.SourceGenerator/Refitter.SourceGenerator.csprojduring test execution.src/Refitter.SourceGenerator.Tests/SourceGeneratorPackageReferenceTests.cswhen the test launches nesteddotnet build/dotnet packcommands againstRefitter.SourceGenerator.csproj.bin/Releaseandobjdirectories, causing file locking/contention onRefitter.SourceGenerator.deps.jsonin CI.Requested change:
src/Refitter.SourceGenerator.Tests/SourceGeneratorPackageReferenceTests.csso the nested build and pack operations use per-test isolated output/intermediate directories under the test workspace.dotnet buildanddotnet packuse the same isolatedOutputPath/BaseIntermediateOutputPath(or equivalent isolated artifact paths) so--no-buildpack can consume the build output without touching the shared repo output directories.Files likely involved:
src/Refitter.SourceGenerator.Tests/SourceGeneratorPackageReferenceTests.cssrc/Refitter.SourceGenerator/Refitter.SourceGenerator.csprojonly if needed for compatibility.Deliverable:
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.
Assistant: The failure is caused by a file-locking race during a nested
dotnet buildofRefitter.SourceGeneratorinside the test run.Root cause
The failing test launches a separate
dotnet buildprocess for the same project while the overall test/build job is already operating in the same repo output directories:src/Refitter.SourceGenerator/Refitter.SourceGenerator.csprojsrc/Refitter.SourceGenerator.Tests/SourceGeneratorPackageReferenceTests.csThe error in the logs is:
GenerateDepsFilefailedSystem.IO.IOException: The process cannot access the file .../src/Refitter.SourceGenerator/bin/Release/netstandard2.0/Refitter.SourceGenerator.deps.jsonThat strongly indicates concurrent access to the same
bin/Release/netstandard2.0output.Why this happens
In the workflow, tests are run after a solution build:
.github/workflows/build.yml:45.github/workflows/build.yml:47During the test run,
SourceGeneratorPackageReferenceTests.BuildSourceGeneratorProject(...)executes:dotnet build src/Refitter.SourceGenerator/Refitter.SourceGenerator.csproj -c Release ...from
SourceGeneratorPackageReferenceTests.cs:102-125.That nested build writes to the normal project output path, which can conflict with other test host activity or multi-targeted test execution. The logs show only
net10.0fails whilenet8.0passes, which is consistent with timing-sensitive file contention rather than a package-content problem.Solution
Isolate the build and pack outputs used by the test into the test workspace instead of writing into the shared project
bin/objfolders.Recommended code change
Update
BuildSourceGeneratorProjectandPackSourceGeneratorPackageto set uniqueBaseIntermediateOutputPath,OutputPath, andPackageOutputPathunder the per-test workspace.Example patch: