[Apple mobile][NativeAOT] Construct the test publish folder instead of stripping extensions in AppleAppBuilder
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Description
## Summary
On Apple mobile NativeAOT the app bundler strips a fixed set of file extensions from the `.app` bundle in `src/tasks/AppleAppBuilder/Xcode.cs` (lines 276 to 284). The stripped extensions are `.dll`, `.pdb`, `.deps.json`, `.runtimeconfig.json`, `.bin` and `.dSYM`. As a result, any test Content file with one of those extensions reaches `publish/` but never lands in the app working directory, so tests that read such a file by path fail with `FileNotFoundException`. The common workaround so far has been to disable those tests.
## Root cause
The blanket extension filter exists because the NativeAOT publish folder still contains managed assemblies that are already compiled into the native image and should not be bundled. The bundler cannot tell those apart from test data that shares the same extension, so it excludes by extension. The TODO right above the exclusion list already calls this out:
> // TODO: All of these exclusions shouldn't be needed once we carefully construct the publish folder on Helix
## Proposed fix
Construct the publish or bundle folder so it contains exactly what should ship, instead of excluding by extension. This removes the whole class of "new test with Content fails on Apple NativeAOT" failures and lets us drop the per-test workarounds.
## Impact and examples
- `System.Diagnostics.FileVersionInfo.Tests.FileVersionInfo_CustomManagedAssembly` failed because `System.Diagnostics.FileVersionInfo.TestAssembly.dll` was stripped. Worked around in #130168 by embedding the assembly as a managed resource and writing it to a temp file at run time.
- Tracked broadly under #126697.
Contributor guide
Research direction
Start in src/tasks/AppleAppBuilder/Xcode.cs, especially lines 276-284 and the TODO above the exclusion list. Trace how the NativeAOT publish or bundle folder is assembled, then check the affected test scenarios described in the issue. Done means valid test Content files, including files with currently excluded extensions, reach the app working directory without bundling managed assemblies that belong only in the native image.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, ios
- Domain
- build-system, mobile-dev, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100