[msbuild] Strip framework metadata by default. Fixes #15724 - #26253
Conversation
Remove Headers, PrivateHeaders, and Modules directories from bundled frameworks before code signing, with StripFrameworkHeaders=false as an opt-out. Invalidate framework copy outputs when the property changes, and preserve Windows remoting long-path coverage by keeping the long fixture in framework resources. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 65a10f7b-f933-4d79-87b2-5056c0f7a3a9
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR adds an MSBuild step to reduce app bundle size by stripping framework metadata directories (Headers, PrivateHeaders, Modules) from embedded .frameworks by default, with a StripFrameworkHeaders=false opt-out. It also ensures incremental builds correctly re-copy frameworks when the property toggles, and updates tests/fixtures to keep Windows long-path coverage without relying on headers that are now stripped.
Changes:
- Add a new
StripFrameworkHeadersMSBuild task and hook it into the app bundle codesign pipeline (enabled by default viaStripFrameworkHeaders=true). - Invalidate directory-copy incremental outputs when
StripFrameworkHeaderschanges (so toggling the property restores/strips headers as expected without a clean build). - Update test fixtures and unit tests to move the long-path fixture file into framework resources and add coverage for the new behavior/property.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test-libraries/frameworks/Makefile | Moves the “long path” fixture from headers into framework resources and adds a simple Headers/test.h for strip/preserve testing. |
| tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/StripFrameworkHeadersTaskTests.cs | Adds unit coverage for the new task to remove the expected directories while preserving unrelated headers and Resources/Headers. |
| tests/dotnet/UnitTests/WindowsTest.cs | Updates Windows long-path assertions to match the new .txt resource fixture and fixes the assertion variable used for matches. |
| tests/dotnet/UnitTests/BundleStructureTest.cs | Updates expected bundle structure for the moved long-path fixture and adds an incremental rebuild test toggling StripFrameworkHeaders. |
| msbuild/Xamarin.Shared/Xamarin.Shared.targets | Registers and runs the new StripFrameworkHeaders task before codesigning. |
| msbuild/Xamarin.Shared/Xamarin.Shared.props | Introduces StripFrameworkHeaders defaulting to true. |
| msbuild/Xamarin.MacDev.Tasks/Tasks/StripFrameworkHeaders.cs | Implements the stripping logic for embedded .framework bundles (including versioned frameworks). |
| dotnet/targets/Xamarin.Shared.Sdk.targets | Adds StripFrameworkHeaders to _CopyDirectoriesToBundle incremental inputs via a small cache file. |
| docs/building-apps/build-properties.md | Documents the new StripFrameworkHeaders property and its default/behavior. |
This comment has been minimized.
This comment has been minimized.
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #9e49ad0] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 203 tests passed 🎉 Tests counts✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. [attempt 2] Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
Remove Headers, PrivateHeaders, and Modules directories from bundled frameworks before code signing, with
StripFrameworkHeaders=falseas an opt-out.Invalidate framework copy outputs when the property changes, and preserve Windows remoting long-path coverage by keeping the long fixture in framework resources.
Tests:
dotnet test tests/msbuild/Xamarin.MacDev.Tasks.Tests/Xamarin.MacDev.Tasks.Tests.csproj --no-restore --filter FullyQualifiedName~StripFrameworkHeadersTaskTestsdotnet build tests/dotnet/UnitTests/DotNetUnitTests.csproj --no-restoreFixes #15724
🤖 Pull request created by Copilot