Skip to content

MSB3030: Intermittent "Could not copy file because it was not found" in parallel builds copying reference PDBs #12927

@ilonatommy

Description

@ilonatommy

Issue Description

Intermittent build failure in CI when building ASP.NET Core with high parallelism. The Copy task fails because a PDB file that was listed in @(ReferenceCopyLocalPaths) gets deleted between evaluation and execution.

Steps to Reproduce

  • Large solution with many project references
  • Build parallelism (/m)
  • Shared output directories
  • Reproduces intermittently on CI

Expected Behavior

Builds without issues.

Actual Behavior

Error:

.dotnet/sdk/10.0.100/Microsoft.Common.CurrentVersion.targets(5080,5): error MSB3030: 
Could not copy the file "/mnt/vss/_work/1/s/artifacts/bin/Microsoft.Net.Http.Headers/Release/net10.0/Microsoft.Net.Http.Headers.pdb" 
because it was not found. [Microsoft.AspNetCore.Authentication.Certificate.csproj]

Evidence:

  • The Microsoft.Net.Http.Headers.dll builds successfully at 00:20:25 (line 1111 in log)
  • Microsoft.Net.Http.Headers.Tests.dll builds at 00:21:06 (line 1187)
  • The error occurs at 00:23:50 (line 1463) when Authentication.Certificate.csproj tries to copy the PDB
  • The error repeats at 00:28:31 on retry

Analysis

Root Cause:

Race condition in the _CopyFilesMarkedCopyLocal target (line 5079-5096 of Microsoft.Common.CurrentVersion.targets). Files are enumerated earlier, but by the time Copy executes, another parallel process may have cleaned/rebuilt that output folder.

Suggested Fix:

Add Condition="Exists('%(FullPath)')" to the Copy task or filter @(ReferenceCopyLocalPaths) before copying in _CopyFilesMarkedCopyLocal.

Logs:

msbuild-copy-not-found.log
original_build

Versions & Configurations

  • .NET SDK: 10.0.100
  • MSBuild: 17.13.x (bundled with SDK 10.0.100)
  • Arcade SDK: 11.0.0-beta.25603.106
  • OS: Linux (Ubuntu via Azure DevOps agent)

Metadata

Metadata

Assignees

Labels

Area: TasksIssues impacting the tasks shipped in Microsoft.Build.Tasks.Core.dll.Priority:1Work that is critical for the release, but we could probably ship withoutauthor-respondedAuthor responded, needs response from dev team.triaged

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions