Skip to content

fix(build): avoid duplicate Content items (NETSDK1022) in targets#3320

Merged
dgozman merged 1 commit into
microsoft:mainfrom
dgozman:fix-3314
Jun 4, 2026
Merged

fix(build): avoid duplicate Content items (NETSDK1022) in targets#3320
dgozman merged 1 commit into
microsoft:mainfrom
dgozman:fix-3314

Conversation

@dgozman
Copy link
Copy Markdown
Collaborator

@dgozman dgozman commented Jun 4, 2026

Summary

  • CopyPlaywrightFilesToOutput could include the same node\LICENSE (and, when the fallback ran, every node file) as a Content item more than once, tripping NETSDK1022 "Duplicate 'Content' items" — a hard error as of .NET 10.
  • The platform-specific globs and the fallback node\** wildcard are now mutually exclusive via an explicit per-platform check; LICENSE is excluded from the fallback wildcard; and the platform-independent LICENSE/package items are declared in their own non-batched ItemGroup so they're added exactly once.

Why the old guard was fragile

The fallback wildcard was gated on '@(_PlaywrightCopyItems->Count())' == '0', intended to copy every platform's binaries only when no platform-specific glob matched. Inside a batched ItemGroup, @(...->Count()) does not reliably observe items added earlier in the same batch — in the reporter's environment it evaluated to 0 even after the platform glob had added items, so the fallback ran in addition to the platform-specific glob. Combined with the unconditional node\LICENSE include, node\LICENSE ended up in Content more than once. The new code drops the Count() dependency entirely.

Fixes #3314

CopyPlaywrightFilesToOutput could emit the same node\LICENSE as a Content
item more than once, tripping the NETSDK1022 "Duplicate Content items" check
(a hard error as of .NET 10).

Make the platform-specific globs and the fallback wildcard mutually exclusive
via an explicit per-platform check, exclude LICENSE from the fallback
wildcard, and declare the platform-independent LICENSE/package items in their
own non-batched ItemGroup so they are added exactly once.

Fixes microsoft#3314
@dgozman dgozman merged commit 4dc5b1d into microsoft:main Jun 4, 2026
16 checks passed
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.

[Bug]: NETSDK1022 "Duplicate Content items" hard build error in .NET 10 projects (Playwright 1.59.0)

2 participants