Repository navigation
Fix parallel-build race when packing ApiCompat.Task / GenAPI.Task test packages - #54567
Merged
Merged
Conversation
BuildTestPackages.targets re-packed Microsoft.DotNet.ApiCompat.Task and Microsoft.DotNet.GenAPI.Task with overridden global properties (PackageOutputPath, Version). That spawns a second MSBuild node which rebuilds their shared ProjectReference Microsoft.DotNet.ApiCompatibility concurrently with the main build, racing on its obj/ output satellite assemblies (e.g. Microsoft.DotNet.ApiCompatibility.resources.dll) and intermittently failing the TestBuild leg with MSB3894/MSB3026. Follow the same approach as dotnet#54380 (Microsoft.TemplateSearch.TemplateDiscovery): drop the BuildTestPackages.targets entries and have each project stage its own nupkg into TestPackagesDir via a CopyPackageToTestPackagesDir target (AfterTargets=Pack). The nupkg is produced by the normal product Pack (these are packable product projects and TestLayoutDir is set repo-wide), so no divergent re-pack node is created and the race is eliminated. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a parallel-build race that can occur when the test infrastructure re-packs already-packed Compatibility task packages (ApiCompat.Task / GenAPI.Task) with different global properties, causing concurrent builds of shared referenced projects and resulting in file-contention failures during packing.
Changes:
- Removes
Microsoft.DotNet.ApiCompat.TaskandMicrosoft.DotNet.GenAPI.TaskfromBuildTestPackages.targetsso they are no longer re-packed with conflicting global properties. - Adds an
AfterTargets="Pack"target to each task project to copy its already-produced.nupkginto$(TestLayoutDir)testpackages/for consumption by Compatibility integration tests. - Updates the exclusion comment in
BuildTestPackages.targetsto document the expanded set of excluded projects and the new copy-to-testpackages mechanism.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/Microsoft.NET.TestFramework/BuildTestPackages.targets | Stops re-packing ApiCompat/GenAPI task packages in the test-package build pipeline to avoid parallel-build contention. |
| src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI.Task/Microsoft.DotNet.GenAPI.Task.csproj | Copies the packed GenAPI task .nupkg into the testpackages feed post-pack for integration test consumption. |
| src/Compatibility/ApiCompat/Microsoft.DotNet.ApiCompat.Task/Microsoft.DotNet.ApiCompat.Task.csproj | Copies the packed ApiCompat task .nupkg into the testpackages feed post-pack for integration test consumption. |
MichaelSimons
approved these changes
Jun 3, 2026
Member
|
@dsplaisted - I am still seeing failures after this fix - example |
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.
Same fix as #54380, this time for ApiCompat and GenAPI.
This was failing in #54410, locally, and probably in other PRs.