Add the property controlling publishing the symbols of reference projects#49707
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new PublishReferencesSymbols property to control publishing of referenced project PDB files, along with default behavior and tests.
- Added
PublishReferencesSymbolsproperty with a default value in MSBuild’s BeforeCommon targets. - Updated publish logic to conditionally include
.pdbfiles based on the new property. - Introduced a theory test to verify symbol publishing when the property is explicitly set.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAProjectWithDependencies.cs | Added a theory test for PublishReferencesSymbols=true/false scenarios. |
| src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.BeforeCommon.targets | Defined <PublishReferencesSymbols> property with a default of true. |
| src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets | Modified the copy-local asset condition to include .pdb when enabled. |
Comments suppressed due to low confidence (1)
test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAProjectWithDependencies.cs:280
- Consider adding a test case for the default behavior (when
PublishReferencesSymbolsisn't specified) to ensure it truly defaults totrueand PDB files are published by default.
[Theory]
| Condition="(('$(PublishReferencesDocumentationFiles)' == 'true' and '%(ReferenceCopyLocalPaths.Extension)' == '.xml') | ||
| or ('$(PublishReferencesSymbols)' == 'true' and '%(ReferenceCopyLocalPaths.Extension)' == '.pdb') | ||
| or ('%(ReferenceCopyLocalPaths.Extension)' != '.xml' and '%(ReferenceCopyLocalPaths.Extension)' != '.pdb')) | ||
| and '%(ReferenceCopyLocalPaths.Private)' != 'false'"> | ||
| <DestinationSubPath>%(ReferenceCopyLocalPaths.DestinationSubDirectory)%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)</DestinationSubPath> | ||
| </_ResolvedCopyLocalPublishAssets> |
There was a problem hiding this comment.
[nitpick] This multi-line Condition is quite verbose and can be hard to maintain; consider breaking it into separate ItemGroups or using intermediate properties to clarify each inclusion rule.
| Condition="(('$(PublishReferencesDocumentationFiles)' == 'true' and '%(ReferenceCopyLocalPaths.Extension)' == '.xml') | |
| or ('$(PublishReferencesSymbols)' == 'true' and '%(ReferenceCopyLocalPaths.Extension)' == '.pdb') | |
| or ('%(ReferenceCopyLocalPaths.Extension)' != '.xml' and '%(ReferenceCopyLocalPaths.Extension)' != '.pdb')) | |
| and '%(ReferenceCopyLocalPaths.Private)' != 'false'"> | |
| <DestinationSubPath>%(ReferenceCopyLocalPaths.DestinationSubDirectory)%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)</DestinationSubPath> | |
| </_ResolvedCopyLocalPublishAssets> | |
| Condition="('$(PublishReferencesDocumentationFiles)' == 'true' and '%(ReferenceCopyLocalPaths.Extension)' == '.xml') or | |
| ('$(PublishReferencesSymbols)' == 'true' and '%(ReferenceCopyLocalPaths.Extension)' == '.pdb') or | |
| ('%(ReferenceCopyLocalPaths.Extension)' != '.xml' and '%(ReferenceCopyLocalPaths.Extension)' != '.pdb')"> | |
| </_ResolvedCopyLocalPublishAssets> | |
| <PropertyGroup> | |
| <IsDocumentationFile Condition="'$(PublishReferencesDocumentationFiles)' == 'true' and '%(ReferenceCopyLocalPaths.Extension)' == '.xml'">true</IsDocumentationFile> | |
| <IsSymbolFile Condition="'$(PublishReferencesSymbols)' == 'true' and '%(ReferenceCopyLocalPaths.Extension)' == '.pdb'">true</IsSymbolFile> | |
| <IsOtherFile Condition="'%(ReferenceCopyLocalPaths.Extension)' != '.xml' and '%(ReferenceCopyLocalPaths.Extension)' != '.pdb'">true</IsOtherFile> | |
| <IsPrivateFile Condition="'%(ReferenceCopyLocalPaths.Private)' != 'false'">true</IsPrivateFile> | |
| </PropertyGroup> | |
| <ItemGroup> | |
| <_ResolvedCopyLocalPublishAssets Include="@(ReferenceCopyLocalPaths)" | |
| Exclude="@(_ResolvedCopyLocalBuildAssets);@(RuntimePackAsset)" | |
| Condition="('$(IsDocumentationFile)' == 'true' or | |
| '$(IsSymbolFile)' == 'true' or | |
| '$(IsOtherFile)' == 'true') and | |
| '$(IsPrivateFile)' == 'true'"> | |
| <DestinationSubPath>%(ReferenceCopyLocalPaths.DestinationSubDirectory)%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)</DestinationSubPath> | |
| </_ResolvedCopyLocalPublishAssets> | |
| </ItemGroup> | |
| <DestinationSubPath>%(ReferenceCopyLocalPaths.DestinationSubDirectory)%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)</DestinationSubPath> | |
| </_ResolvedCopyLocalPublishAssets> |
|
@rainersigwald can you please take a look? |
|
@baronfel could you please check this PR? |
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.BeforeCommon.targets
Show resolved
Hide resolved
|
I added the |
Please review the doc pr dotnet/docs#50255. |
Fix dotnet/msbuild#12044
Add the property
PublishReferenceSymbolsto control whether the .pdb file of the referenced project is published to the publish folder.