Skip to content

Keep Publish* properties across Restore so that we can gather all required implicit packages #49501

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

baronfel
Copy link
Member

Fixes #49493

Before, when the implicit Restore was triggered for the packages we would unconditionally set the Publish* properties to false. This caused Restore to not add the implicit packages to the trimming tools, so later when the ILLink target was called we'd invoke the dummy one from the SDK, not the actual one from the ILLink targets package.

Added a test that checks the trimmed package contents and ensures that a dll whose functionality we never use is not in the package. We could also do a size-based check here - the trimmed packages are currently ~9MB vs the full packages which are ~25MB.

@baronfel baronfel requested review from Copilot and a team June 19, 2025 23:13
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR preserves publishing-related MSBuild properties during restore to ensure implicit packages (like trimming tools) are correctly included and adds tests to verify trimmed tool packages exclude unused DLLs.

  • Introduce a Trimmed flag in TestToolBuilder and update identifier logic
  • Add an end-to-end test for trimmed tools checking package contents
  • Update Microsoft.NET.PackTool.targets to guard publish properties by MSBuildIsRestoring

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
test/Microsoft.DotNet.PackageInstall.Tests/TestToolBuilder.cs Add Trimmed setting and adjust identifier and project properties
test/Microsoft.DotNet.PackageInstall.Tests/EndToEndToolTests.cs Add PackagesMultipleTrimmedToolsWithASingleInvocation test
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackTool.targets Preserve publish properties when restoring by checking MSBuildIsRestoring
Comments suppressed due to low confidence (1)

test/Microsoft.DotNet.PackageInstall.Tests/EndToEndToolTests.cs:211

  • The XML doc refers to 'dependency' but the method checks for file entries; consider updating the summary to clarify it checks for absent files in the package.
        /// Opens the nupkg and verifies that it does not contain a dependency on the given dll.

@marcpopMSFT
Copy link
Member

It's possible that SelfContained doesn't matter here but the rest do and it's related to the inferences we make earlier in evaluation.

@marcpopMSFT marcpopMSFT merged commit ee24868 into dotnet:main Jun 24, 2025
30 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.

multi-RID tool packaging doesn't correctly handle trimming scenarios
2 participants