[dotnet] Fix CoreCLR framework signing with correct Info.plist tracking. Fixes #25248.#25254
Conversation
…ist tracking. Fixes #25248. Fix three issues with the dylib-to-framework conversion for CoreCLR iOS/tvOS device builds: 1. _CreateInfoPlistForFrameworks used the hash string value instead of the hash file path in its Inputs, making the target always appear out-of-date. 2. _CopyDirectoriesToBundle only tracked the framework binary timestamp in its Inputs, not the Info.plist. If the Info.plist changed (e.g., bundle ID change) but the binary didn't, the copy was skipped and the app bundle could have a stale or missing Info.plist. 3. The bundle identifier ($(_BundleIdentifier)) was not included in the hash inputs for _ComputeFrameworksToCreate, so changing ApplicationId would not trigger Info.plist regeneration for converted frameworks. These issues could result in framework bundles being signed without a valid Info.plist, causing codesign to treat them as bare Mach-O files instead of framework bundles. iOS then rejects the app at install time with MismatchedBundleIDSigningIdentifier. Fixes #25248 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The R2R framework uses '<bundleid>.r2rframework' as its CFBundleIdentifier, not '<bundleid>.<frameworkname>'. Update the test to verify the identifier starts with the app bundle identifier prefix rather than matching an exact pattern, and check that codesign uses the same identifier as the Info.plist. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
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
Fixes incremental-build issues that could leave converted CoreCLR dylib frameworks with missing/stale Info.plist, causing codesign to sign them as bare Mach-O binaries and resulting in device install failures (MismatchedBundleIDSigningIdentifier).
Changes:
- Fix
_CreateInfoPlistForFrameworksincremental inputs by tracking a hash file (not a hash string) and including the bundle identifier in the hashed inputs. - Attempt to make
_CopyDirectoriesToBundlererun when frameworkInfo.plistchanges by adding additional Inputs. - Add a unit test validating that bundled
.frameworkdirectories contain a correctInfo.plistand (when signed) have matchingcodesignidentifiers.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
dotnet/targets/Microsoft.Sdk.R2R.targets |
Improves incremental build correctness for generating framework Info.plist by tracking stable inputs. |
dotnet/targets/Xamarin.Shared.Sdk.targets |
Extends copy target Inputs to include Info.plist changes (but current implementation appears ineffective; see comments). |
tests/dotnet/UnitTests/PostBuildTest.cs |
Adds a regression test for CoreCLR-converted frameworks’ Info.plist and signing behavior. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
- Fix _DirectoriesToPublishInfoPlist to derive Info.plist path from SourceDirectory metadata instead of non-existent AppManifestPath metadata. - Remove null-forgiving operators in test, use proper Assert.That assertions. - Assert codesign exit code to avoid unused variable warning. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #182ce4b] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 161 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
Summary
Fix incremental-build bugs that could cause CoreCLR framework bundles (converted from dylibs) to be missing or have stale Info.plist files, leading to codesign signing them as bare Mach-O binaries instead of framework bundles. This results in a mismatched bundle ID / signing identifier, which causes iOS device installs to fail with
MismatchedBundleIDSigningIdentifier.Changes
MSBuild targets fixes (
Microsoft.Sdk.R2R.targets)Fixed
_CreateInfoPlistForFrameworksInputs: Changed from using the hash string ($(_ComputeFrameworksToCreateAppManifestHashedInputs)) to the hash file path ($(_ComputeFrameworksToCreateAppManifestHashedInputsPath)). The hash string is computed at evaluation time and always changes, defeating incremental build skipping.Added
$(_BundleIdentifier)to hash inputs: The bundle identifier flows into the generated Info.plist'sCFBundleIdentifier, so changes to it must trigger regeneration.MSBuild targets fixes (
Xamarin.Shared.Sdk.targets)_CopyDirectoriesToBundle: The target's Inputs only tracked framework binary timestamps (via_DirectoriesToPublish), not their Info.plist files. If the Info.plist was regenerated but the binary wasn't, the copy step would be skipped and the app bundle would have a stale or missing Info.plist.Unit test (
PostBuildTest.cs)Added
CoreCLR_ConvertedFrameworks_HaveInfoPlisttest (iOS + tvOS) that verifies:.frameworkdirectory contains an Info.plistFixes #25248
🤖 Pull request created by Copilot