Skip to content

Fix NU5026: exclude PDB files from CopyProjectReferencesToPackage in TemplateLocator and Containers#54494

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-main-ci-build-error
Draft

Fix NU5026: exclude PDB files from CopyProjectReferencesToPackage in TemplateLocator and Containers#54494
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-main-ci-build-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 28, 2026

Main CI failing on macOS and Windows with NU5026 because CopyProjectReferencesToPackage was adding .pdb files from ReferenceCopyLocalPaths into BuildOutputInPackage, but those PDBs don't exist on disk when pack runs in official builds.

Root cause: Arcade SDK's Workarounds.targets adds .pdb to AllowedOutputExtensionsInPackageBuildOutputFolder when DebugType=portable (set globally by Arcade when OfficialBuildId is set), allowing PDB files to be included in packages. Both TemplateLocator and Microsoft.NET.Build.Containers use CopyProjectReferencesToPackage targets that add all ReferenceCopyLocalPaths — DLLs and PDBs alike — to BuildOutputInPackage. In official distributed builds, only DLLs are transferred between build agents, so PDB files don't exist on disk when pack runs, causing NU5026. Non-official builds use DebugType=embedded (no separate .pdb), so the issue never surfaces locally.

Fix: In both projects, stage the copy-local paths into an intermediate item and exclude .pdb extensions before adding to BuildOutputInPackage.

Microsoft.DotNet.TemplateLocator (macOS NativeWrapper.pdb failure):

<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences">
  <ItemGroup>
    <_ProjectReferenceOutputs Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
    <!-- Exclude .pdb files: in official builds (DebugType=portable) they are published via the symbol server,
         not bundled inside the NuGet package. -->
    <BuildOutputInPackage Include="@(_ProjectReferenceOutputs)" Condition="'%(_ProjectReferenceOutputs.Extension)' != '.pdb'" />
  </ItemGroup>
</Target>

Microsoft.NET.Build.Containers (Windows Cli.Utils.pdb failure):

<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences">
  <ItemGroup>
    <_LocalPaths Include="@(ReferenceCopyLocalPaths)" />
    <!-- Exclude .pdb files: in official builds (DebugType=portable) they are published via the symbol server,
         not bundled inside the NuGet package. -->
    <BuildOutputInPackage Include="@(_LocalPaths)" TargetPath="%(_LocalPaths.DestinationSubPath)" Condition="'%(_LocalPaths.Extension)' != '.pdb'" />
  </ItemGroup>
</Target>

PDB files belong in their own symbol packages, not bundled inside the NuGet packages.

…cator

Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
Copilot AI changed the title Fix NU5026: exclude PDB files from BuildOutputInPackage in TemplateLocator pack Fix NU5026: exclude PDB files from TemplateLocator's CopyProjectReferencesToPackage May 28, 2026
Copilot AI requested a review from marcpopMSFT May 28, 2026 17:01
@marcpopMSFT
Copy link
Copy Markdown
Member

@copilot main CI is failing with a few other errors I can see:
##[error].dotnet/sdk/11.0.100-preview.5.26227.104/NuGet.Build.Tasks.Pack.targets(222,5): error NU5026: (NETCORE_ENGINEERING_TELEMETRY=Build) The file '/Users/runner/work/1/s/artifacts/bin/Microsoft.DotNet.NativeWrapper/Release/net11.0/Microsoft.DotNet.NativeWrapper.pdb' to be packed was not found on disk.
##[error].dotnet/sdk/11.0.100-preview.5.26227.104/Microsoft.Common.CurrentVersion.targets(5096,5): error MSB3894: (NETCORE_ENGINEERING_TELEMETRY=Build) Got System.IO.IOException: The process cannot access the file '/mnt/vss/_work/1/s/artifacts/bin/Microsoft.DotNet.ApiCompat.Tool/Release/net10.0/NuGet.Packaging.dll' because it is being used by another process.
##[error].dotnet\sdk\11.0.100-preview.5.26227.104\NuGet.Build.Tasks.Pack.targets(222,5): error NU5026: (NETCORE_ENGINEERING_TELEMETRY=Build) The file 'D:\a\_work\1\s\artifacts\bin\Microsoft.DotNet.Cli.Utils\Release\net11.0\Microsoft.DotNet.Cli.Utils.pdb' to be packed was not found on disk.

…ld.Containers

Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jun 1, 2026

@copilot main CI is failing with a few other errors I can see:
`##[error].dotnet/sdk/11.0.100-preview.5.26227.104/NuGet.Build.Tasks.Pack.targets(222,5): error NU5026: (NETCORE_ENGINEERING_TELEMETRY=B...

Applied the same .pdb exclusion fix to Microsoft.NET.Build.Containers's CopyProjectReferencesToPackage target (commit $(git rev-parse --short HEAD)).

Root cause for both failures: Arcade SDK's Workarounds.targets adds .pdb to AllowedOutputExtensionsInPackageBuildOutputFolder when DebugType=portable (set globally in official builds). Both TemplateLocator and Microsoft.NET.Build.Containers use CopyProjectReferencesToPackage to add ReferenceCopyLocalPaths to BuildOutputInPackage — including .pdb files. In the distributed official build, only DLLs are transferred between agents, so the PDB files don't exist on disk when pack runs, causing NU5026.

The MSB3894 file-lock error on the other agent is a transient build parallelism issue, not related to this PR.

Copilot AI changed the title Fix NU5026: exclude PDB files from TemplateLocator's CopyProjectReferencesToPackage Fix NU5026: exclude PDB files from CopyProjectReferencesToPackage in TemplateLocator and Containers Jun 1, 2026
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