Repository navigation
Respect SatelliteResourceLanguages in Microsoft.CodeCoverage.targets - #16811
Open
Yitzhak Steinmetz (yitzhaks) wants to merge 2 commits into
Open
Yitzhak Steinmetz (yitzhaks) wants to merge 2 commits into
Yitzhak Steinmetz (yitzhaks) wants to merge 2 commits into
Conversation
CopyTraceDataCollectorArtifacts runs after ComputeFilesToPublish (and therefore after the .NET SDK's _FilterSatelliteResourcesForPublish target) and previously added all localized *.resources.dll files from build\netstandard2.0\<culture>\ unconditionally to ResolvedFileToPublish. Filter localized *.resources.dll items in TraceDataCollectorArtifacts against $(SatelliteResourceLanguages) (case-insensitive) when set, leaving behavior unchanged when SatelliteResourceLanguages is unset or empty. Add acceptance tests covering unset, empty, single-locale, multi-locale, case-insensitive/whitespace-padded lists, and end-to-end published coverage collection with SatelliteResourceLanguages=en-US. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f3af7923-4d0e-4868-8504-a1d24c0b941f
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The satellite resource filtering change has no active review issues.
No open issues 🎉
What changed in this PR
Updates VSTest’s code coverage publishing to honor SatelliteResourceLanguages, addressing the localized resources left in publish output described in #2057.
Changes:
- Filters satellite assemblies by requested cultures while preserving non-satellite files and existing behavior when the property is empty.
- Adds acceptance tests for language filtering and coverage collection after publishing.
| File | Description |
|---|---|
test/Microsoft.TestPlatform.Acceptance.IntegrationTests/CodeCoveragePublishTests.cs |
Tests culture filtering and published coverage collection. |
src/package/Microsoft.CodeCoverage/Microsoft.CodeCoverage.targets |
Filters published satellite resources by requested languages. |
Review effort: Balanced
Gate the satellite filtering PropertyGroup and ItemGroup in CopyTraceDataCollectorArtifacts on '@(_MsCoverageSatelliteResourceLanguages)' != '' so whitespace-only or semicolon-only values (which expand to an empty item list) preserve all satellites instead of stripping them. Expand PublishRespectsSatelliteResourceLanguages to cover whitespace-only, semicolon-only, and nested culture directory cases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f3af7923-4d0e-4868-8504-a1d24c0b941f
| Condition="'%(TraceDataCollectorArtifacts.RecursiveDir)' != '' and $([System.String]::Copy('%(TraceDataCollectorArtifacts.Filename)%(TraceDataCollectorArtifacts.Extension)').ToLowerInvariant().EndsWith('.resources.dll'))"> | ||
| <_Culture>$([System.String]::Copy('%(TraceDataCollectorArtifacts.RecursiveDir)').TrimEnd('\').TrimEnd('/'))</_Culture> | ||
| </_MsCoverageSatelliteArtifacts> | ||
| <_MsCoverageSatelliteArtifacts Update="@(_MsCoverageSatelliteArtifacts)"> |
This branch has not been deployed
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.

Description
Summary
Microsoft.CodeCoverage'sCopyTraceDataCollectorArtifactstarget (AfterTargets="ComputeFilesToPublish") runs after the .NET SDK's_FilterSatelliteResourcesForPublishtarget and previously added all files under$(MSBuildThisFileDirectory)\**\*.*unconditionally toResolvedFileToPublish. As a result, settingSatelliteResourceLanguages(for exampleen-US) had no effect on the 13 localized culture folders (cs,de,es,fr,it,ja,ko,pl,pt-BR,ru,tr,zh-Hans,zh-Hant) ofMicrosoft.VisualStudio.TraceDataCollector.resources.dllandMicrosoft.CodeCoverage.Core.resources.dllcopied duringdotnet publish.This change updates
CopyTraceDataCollectorArtifactsinsrc/package/Microsoft.CodeCoverage/Microsoft.CodeCoverage.targetsto filter localized*.resources.dllitems inTraceDataCollectorArtifactsby their culture subfolder against$(SatelliteResourceLanguages)(case-insensitive, matching.NET SDK's_FilterSatelliteResourcesForPublishandMSTest.TestAdapter):$(SatelliteResourceLanguages)is unset, empty, or contains no non-empty language entries (e.g., whitespace/semicolon-only), behavior is unchanged and all localized satellite folders are preserved.$(SatelliteResourceLanguages)contains one or more language entries, only localized*.resources.dllfiles whose culture folder matches one of the specified languages are included; all non-satellite collector assemblies, native binaries, and config/target files remain unaffected.Impact
SatelliteResourceLanguagesexcludes those locales (compounding across large multi-project and multi-targeted repositories, packaging manifests, and CI/deployment drops).SatelliteResourceLanguagessemantics: AlignsMicrosoft.CodeCoveragewith standard .NET SDK publish filtering andMSTest.TestAdapter.SatelliteResourceLanguagessee no behavioral change. Projects that setSatelliteResourceLanguagesretain all non-satellite code coverage binaries and can still collect coverage from published outputs as before.Validation
.\build.cmd -c Release -pack) and ran.\eng\verify-nupkgs.ps1.test/Microsoft.TestPlatform.Acceptance.IntegrationTests/CodeCoveragePublishTests.cs:PublishRespectsSatelliteResourceLanguagescovering unset, empty, whitespace-only (" "), semicolon/whitespace-only (" ; "),en-US, multi-locale (en-US;fr;de), mixed-case/whitespace-padded (en-US; PT-br ; ZH-HANS), and nested culture subdirectories (CodeCoverage/fr/...).PublishedTestsRespectSatelliteResourceLanguagesverifying end-to-enddotnet publish -p:SatelliteResourceLanguages=en-USwith the locally packedMicrosoft.CodeCoveragepackage copies zero*.resources.dllfiles whiledotnet vstest /collect:"Code Coverage;Format=cobertura"still succeeds and produces coverage.CodeCoveragePublishTestspass in Release.Related issue
Relates to #2057.