KEMBAR78
[msbuild] Fix FilterStaticFrameworks task to support custom framework binary names by Copilot · Pull Request #23045 · dotnet/macios · GitHub
Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jun 13, 2025

The FilterStaticFrameworks MSBuild task was hardcoded to assume framework executables are always located at Framework.framework/Framework, but some frameworks (like FFmpeg's libavcodec) use custom executable paths specified in their Info.plist via the CFBundleExecutable property.

This caused build failures with frameworks that use custom binary names:

error MT158: The file '/path/to/libavcodec.framework/libavcodec' does not exist.

The actual executable was at libavcodec.framework/libavcodec.dylib as specified in the framework's Info.plist CFBundleExecutable property.

Solution

Added a GetFrameworkExecutablePath helper method that:

  1. Reads Info.plist: Checks for CFBundleExecutable property in framework's Info.plist
  2. Uses custom path: Returns the path specified by CFBundleExecutable when present
  3. Falls back gracefully: Uses default behavior for standard frameworks or when Info.plist is missing/corrupt
  4. Maintains compatibility: All existing frameworks continue to work unchanged

Example

Before (fails):

libavcodec.framework/
├── Info.plist  # CFBundleExecutable = "libavcodec.dylib"
└── libavcodec.dylib

Task looks for: libavcodec.framework/libavcodec

After (works):
Task reads Info.plist and looks for: libavcodec.framework/libavcodec.dylib

Testing

Added comprehensive tests covering:

  • ✅ Custom CFBundleExecutable scenarios (reproduces the original issue)
  • ✅ Standard frameworks without Info.plist (backward compatibility)
  • ✅ Non-framework paths (edge case handling)
  • ✅ Error handling for malformed/missing Info.plist files

Fixes #23039.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: rolfbjarne <249268+rolfbjarne@users.noreply.github.com>
Copilot AI changed the title [WIP] FilterStaticFrameworks task doesn't support custom Framework binary names Fix FilterStaticFrameworks task to support custom framework binary names Jun 13, 2025
Copilot AI requested a review from rolfbjarne June 13, 2025 18:23
Copilot finished work on behalf of rolfbjarne June 13, 2025 18:23
Comment on lines 31 to 39
try {
var plist = PDictionary.FromFile (infoPlistPath);
var bundleExecutable = plist?.GetCFBundleExecutable ();
if (!string.IsNullOrEmpty (bundleExecutable)) {
return Path.Combine (frameworkPath, bundleExecutable);
}
} catch {
// If reading the plist fails, fall back to the default behavior
}
Copy link
Member

Choose a reason for hiding this comment

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

FromFile does not raise any exception, what exception are you trying to catch? This can me cleaner with a if statement no need for the try/catch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right! I've simplified the code by removing the try-catch and using explicit null checking instead. Since GetFrameworkExecutablePath is called within a larger try-catch block that handles framework validation errors appropriately, any exceptions from PDictionary.FromFile will be caught and logged with proper error messages. The refactored code is cleaner and follows the patterns used elsewhere in the codebase. Fixed in d3f208c.


static string GetFrameworkExecutablePath (string frameworkPath)
{
if (!frameworkPath.EndsWith (".framework", StringComparison.OrdinalIgnoreCase) || !Directory.Exists (frameworkPath))
Copy link
Member

Choose a reason for hiding this comment

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

Simplify the || to use an and so that it can be short circuit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simplified the logical condition to use && with short-circuiting instead of ||. The change is logically equivalent but more efficient - if the path doesn't end with ".framework", we skip the Directory.Exists check entirely. Fixed in 0b203a4.

Co-authored-by: mandel-macaque <2190086+mandel-macaque@users.noreply.github.com>
Co-authored-by: mandel-macaque <2190086+mandel-macaque@users.noreply.github.com>
Copilot finished work on behalf of mandel-macaque June 13, 2025 18:46
@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Contributor Author

Copilot AI commented Jun 13, 2025

@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: cb9e1c42-de13-48b7-b6df-6c5a01d20da4

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Contributor Author

Copilot AI commented Jun 13, 2025

@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 17f50e8e-5c07-48bd-b0a6-bd3ed9a7a89e

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Contributor Author

Copilot AI commented Jun 13, 2025

@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 4be25d47-1581-484e-82e7-970da6b92d8e

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Contributor Author

Copilot AI commented Jun 13, 2025

@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: dcf50cd4-9439-4ec9-992b-43610425540e

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Contributor Author

Copilot AI commented Jun 13, 2025

@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 6c8ca4e4-da9c-4123-b939-726c033e967b

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Contributor Author

Copilot AI commented Jun 13, 2025

@vs-mobiletools-engineering-service2 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 4c5bad3c-8c72-4003-b1a0-b90e4818cd77

Sorry for the inconvenience!

@vs-mobiletools-engineering-service2

This comment has been minimized.

Co-authored-by: rolfbjarne <249268+rolfbjarne@users.noreply.github.com>
Copilot AI requested a review from rolfbjarne August 7, 2025 10:12
Copilot finished work on behalf of rolfbjarne August 7, 2025 10:12
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [PR Build #40fb53e] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 40fb53e7527f52a7591ad63894f49e3bf9010c78 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #40fb53e] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 40fb53e7527f52a7591ad63894f49e3bf9010c78 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

.NET ( No breaking changes )

✅ API diff vs stable

.NET ( No breaking changes )

ℹ️ Generator diff

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

Pipeline on Agent
Hash: 40fb53e7527f52a7591ad63894f49e3bf9010c78 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #40fb53e] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 40fb53e7527f52a7591ad63894f49e3bf9010c78 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #40fb53e] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: 40fb53e7527f52a7591ad63894f49e3bf9010c78 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #40fb53e] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: 40fb53e7527f52a7591ad63894f49e3bf9010c78 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #40fb53e] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: 40fb53e7527f52a7591ad63894f49e3bf9010c78 [PR build]

@rolfbjarne rolfbjarne marked this pull request as ready for review August 7, 2025 11:57
@rolfbjarne rolfbjarne requested review from emaf and mauroa as code owners August 7, 2025 11:57
@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #40fb53e] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: 40fb53e7527f52a7591ad63894f49e3bf9010c78 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #40fb53e] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 115 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. 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. 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: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 8 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 8 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 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

Pipeline on Agent
Hash: 40fb53e7527f52a7591ad63894f49e3bf9010c78 [PR build]

@rolfbjarne rolfbjarne merged commit ec08bde into main Aug 11, 2025
44 checks passed
@rolfbjarne rolfbjarne deleted the copilot/fix-23039 branch August 11, 2025 10:18
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.

FilterStaticFrameworks task doesn't support custom Framework binary names

7 participants