Repository navigation
Exclude .pdb of non-publishable project references from publish output - #56175
Merged
Merged
Conversation
|
Azure Pipelines: 3 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
… output Co-authored-by: marcpopMSFT <[email protected]>
Copilot
AI
changed the title
[WIP] Fix unnecessary .pdb files in publish directory
Exclude .pdb of non-publishable project references from publish output
Sep 8, 2026
marcpopMSFT
marked this pull request as ready for review
September 21, 2026 22:50
marcpopMSFT
requested review from
dsplaisted
and
a lite review from Copilot
September 21, 2026 22:50
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Member
|
Tested in codespace that publish of a IsPublishable reference no longer includes the pdb |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved review issues remain.
Review effort: Lite
Findings: None
What changed in this PR
This pull request excludes .pdb files from non-publishable project references while retaining their required runtime assemblies.
Changes:
- Propagates
IsPublishablemetadata through project-reference target paths. - Filters non-publishable referenced symbols from publish output.
- Adds regression test coverage.
| File | Description |
|---|---|
test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAProjectWithDependencies.cs |
Verifies DLL inclusion and PDB exclusion. |
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets |
Adds metadata propagation and filters referenced PDBs. |
marcpopMSFT
enabled auto-merge (squash)
September 22, 2026 20:29
baronfel
approved these changes
Sep 22, 2026
baronfel
left a comment
Member
There was a problem hiding this comment.
I like the separation of the source of the data (the referenced project) from the consumer of the data (the referencing project)!
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.
Referenced projects marked
IsPublishable=falsecorrectly had their outputs excluded from the publish directory — except for their.pdbfile, which was always copied wheneverPublishReferencesSymbols=true(the default).Root cause
ReferenceCopyLocalPathsitems (populated by MSBuild's assembly reference resolution for project references, including the auto-discovered.pdbsibling of a referenced.dll) carried no information about the referenced project'sIsPublishablevalue, so the publish logic had no signal to exclude it.Fix
Microsoft.NET.Publish.targets: added a target (AfterTargets="GetTargetPathWithTargetPlatformMoniker") that stamps$(IsPublishable)onto@(TargetPathWithTargetPlatformMoniker), the item returned via the standardGetTargetPathproject-reference protocol. This metadata flows through to the referencing project'sReferenceCopyLocalPathsitems, including the related.pdb._ComputeResolvedCopyLocalPublishAssetsto only copy a referenced.pdbwhen%(ReferenceCopyLocalPaths.IsPublishable) != 'false'. The referenced.dllis unaffected and still copied, since it's required at run time.Tests
It_does_not_publish_symbols_of_a_non_publishable_referenced_project, asserting a referenced project's.dllis published but its.pdbis not whenIsPublishable=false.