Skip to content

[msbuild] Strip framework metadata by default. Fixes #15724 - #26253

Merged
rolfbjarne merged 1 commit into
mainfrom
dev/rolf/dev-rolf-issue-15724-module-header-opt-o
Jul 29, 2026
Merged

[msbuild] Strip framework metadata by default. Fixes #15724#26253
rolfbjarne merged 1 commit into
mainfrom
dev/rolf/dev-rolf-issue-15724-module-header-opt-o

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

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.

Tests:

  • dotnet test tests/msbuild/Xamarin.MacDev.Tasks.Tests/Xamarin.MacDev.Tasks.Tests.csproj --no-restore --filter FullyQualifiedName~StripFrameworkHeadersTaskTests
  • dotnet build tests/dotnet/UnitTests/DotNetUnitTests.csproj --no-restore

Fixes #15724

🤖 Pull request created by Copilot

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
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 StripFrameworkHeaders MSBuild task and hook it into the app bundle codesign pipeline (enabled by default via StripFrameworkHeaders=true).
  • Invalidate directory-copy incremental outputs when StripFrameworkHeaders changes (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.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne
rolfbjarne marked this pull request as ready for review July 24, 2026 06:07
@rolfbjarne
rolfbjarne requested a review from mauroa as a code owner July 24, 2026 06:07
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 9e49ad0064c2591459f498ccd0a457d273154764 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [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
✅ cecil: All 1 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 15 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 18 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (macOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 19 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: 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
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: 9e49ad0064c2591459f498ccd0a457d273154764 [PR build]

@rolfbjarne rolfbjarne added the ready-to-review This PR is ready to review/merge. label Jul 27, 2026
@rolfbjarne
rolfbjarne merged commit aaf195f into main Jul 29, 2026
57 checks passed
@rolfbjarne
rolfbjarne deleted the dev/rolf/dev-rolf-issue-15724-module-header-opt-o branch July 29, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot ready-to-review This PR is ready to review/merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Module header files are not stripped from ipa package

5 participants