Skip to content

Fix parallel-build race when packing ApiCompat.Task / GenAPI.Task test packages - #54567

Merged
MichaelSimons merged 1 commit into
dotnet:mainfrom
dsplaisted:apicompat-race
Jun 3, 2026
Merged

MichaelSimons merged 1 commit into
dotnet:mainfrom
dsplaisted:apicompat-race

Conversation

@dsplaisted

Copy link
Copy Markdown
Member

Same fix as #54380, this time for ApiCompat and GenAPI.

This was failing in #54410, locally, and probably in other PRs.

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>
@dsplaisted
dsplaisted requested review from a team and marcpopMSFT June 3, 2026 01:00
@dsplaisted
dsplaisted requested a review from a team as a code owner June 3, 2026 01:00
Copilot AI review requested due to automatic review settings June 3, 2026 01:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.Task and Microsoft.DotNet.GenAPI.Task from BuildTestPackages.targets so they are no longer re-packed with conflicting global properties.
  • Adds an AfterTargets="Pack" target to each task project to copy its already-produced .nupkg into $(TestLayoutDir)testpackages/ for consumption by Compatibility integration tests.
  • Updates the exclusion comment in BuildTestPackages.targets to 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
MichaelSimons merged commit 056c1c1 into dotnet:main Jun 3, 2026
26 checks passed
@MichaelSimons

Copy link
Copy Markdown
Member

@dsplaisted - I am still seeing failures after this fix - example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants