Build Information
Build: 1403076 (2026-04-30T10:36:57Z)
Affected jobs:
- maccatalyst-arm64 Release AllSubsets_CoreCLR
- maccatalyst-x64 Release AllSubsets_CoreCLR
- iossimulator-x64 Release AllSubsets_CoreCLR
- iossimulator-arm64 Release (Mono and CoreCLR)
- tvos-arm64 Release (Mono and CoreCLR variants)
Error
ILLink trimmer fails during library test build with assembly resolution errors:
error IL2007: Could not resolve assembly 'System.Runtime.Loader.Test.Assembly'.
error IL2007: Could not resolve assembly 'System.Runtime.Loader.Test.Assembly2'.
error NETSDK1144: Optimizing assemblies for size failed.
Source: src/libraries/System.Runtime.Loader/tests/ILLink.Descriptors.xml lines 5-6 reference test assemblies that are not available when the trimmer runs.
ILLink.Descriptors.xml content:
<linker>
<assembly fullname="LoaderLinkTest.Dynamic" />
<assembly fullname="ReferencedClassLib" />
<assembly fullname="ReferencedClassLibNeutralIsSatellite" />
<assembly fullname="System.Runtime.Loader.Test.Assembly" />
<assembly fullname="System.Runtime.Loader.Test.Assembly2" />
</linker>
Analysis
Root cause: Build dependency ordering issue. The test assemblies System.Runtime.Loader.Test.Assembly and System.Runtime.Loader.Test.Assembly2 are separate projects under src/libraries/System.Runtime.Loader/tests/ that must be built before the main test project runs ILLink trimming.
On desktop and non-trimmed platforms, this works because:
- Either trimming is disabled, or
- The build dependency graph ensures test assemblies are built first
On Apple mobile platforms (iOS, tvOS, macCatalyst), the aggressive trimming configuration (used for app bundle size optimization) runs ILLink during the main test project build, but the dependency projects might not be referenced/built in the correct order for trimming purposes.
Evidence:
- The test assembly projects exist in the source tree:
System.Runtime.Loader.Test.Assembly/System.Runtime.Loader.Test.Assembly.csproj
System.Runtime.Loader.Test.Assembly2/ (similar structure)
- Other test assemblies referenced in the same descriptor (LoaderLinkTest.Dynamic, ReferencedClassLib) may build earlier in the dependency chain
- The error is trimmer-specific (
IL2007 from ILLink, not a compiler error)
Impact
Blocks all System.Runtime.Loader library tests from running on Apple mobile platforms:
- 0 tests executed (build fails before test packaging)
- Affects 6 mobile platform/architecture combinations across CoreCLR and Mono
- Test coverage gap for AssemblyLoadContext, collectible assemblies, and metadata update APIs on mobile
Recommended action
Option 1: Fix build dependencies (preferred)
Ensure System.Runtime.Loader.Test.Assembly and System.Runtime.Loader.Test.Assembly2 are built (or at least their assembly references are available) before ILLink runs on the main test project. This may require:
- Adding explicit
ProjectReference elements in System.Runtime.Loader.Tests.csproj (if not already present)
- Checking MSBuild target ordering to ensure dependency assemblies are resolved before
RunILLink target
- Verifying the dependencies are included in the mobile-specific build graph (
eng/testing/tests.ioslike.targets, etc.)
Option 2: Conditional descriptor inclusion
Exclude the problematic assembly references from the ILLink descriptor on mobile platforms:
<linker>
<assembly fullname="LoaderLinkTest.Dynamic" />
<assembly fullname="ReferencedClassLib" />
<assembly fullname="ReferencedClassLibNeutralIsSatellite" />
<!-- Only preserve test assemblies when they're actually built -->
<assembly fullname="System.Runtime.Loader.Test.Assembly" Condition="..." />
<assembly fullname="System.Runtime.Loader.Test.Assembly2" Condition="..." />
</linker>
However, ILLink descriptor XML does not support MSBuild conditions directly. This would require preprocessing or splitting descriptors.
Option 3: Disable these specific tests on mobile (workaround)
If the tests genuinely depend on dynamic assembly loading features unavailable on trimmed/AOT mobile platforms, exclude the affected test methods with [SkipOnPlatform] or adjust TargetFrameworks in the csproj. But first verify if that's actually the case — many AssemblyLoadContext tests should work on mobile.
Investigation steps
- Check project references: Does
System.Runtime.Loader.Tests.csproj have <ProjectReference> for the test assembly projects? If not, add them.
- Check build logs: On a successful desktop build, confirm the dependency assemblies are built before the main test project's ILLink step. Compare with the failed mobile build.
- Check mobile-specific target files: Review
eng/testing/tests.ioslike.targets and src/mono/msbuild/apple/build/AppleBuild.targets for custom dependency handling.
- Test locally: Build System.Runtime.Loader.Tests for
iossimulator-x64 with verbose MSBuild logging to see the exact dependency resolution and trimming order.
Related issues
Generated by Mobile Platform Failure Scanner · ● 3.1M · ◷
Build Information
Build: 1403076 (2026-04-30T10:36:57Z)
Affected jobs:
Error
ILLink trimmer fails during library test build with assembly resolution errors:
Source:
src/libraries/System.Runtime.Loader/tests/ILLink.Descriptors.xmllines 5-6 reference test assemblies that are not available when the trimmer runs.ILLink.Descriptors.xml content:
Analysis
Root cause: Build dependency ordering issue. The test assemblies
System.Runtime.Loader.Test.AssemblyandSystem.Runtime.Loader.Test.Assembly2are separate projects undersrc/libraries/System.Runtime.Loader/tests/that must be built before the main test project runs ILLink trimming.On desktop and non-trimmed platforms, this works because:
On Apple mobile platforms (iOS, tvOS, macCatalyst), the aggressive trimming configuration (used for app bundle size optimization) runs ILLink during the main test project build, but the dependency projects might not be referenced/built in the correct order for trimming purposes.
Evidence:
System.Runtime.Loader.Test.Assembly/System.Runtime.Loader.Test.Assembly.csprojSystem.Runtime.Loader.Test.Assembly2/(similar structure)IL2007from ILLink, not a compiler error)Impact
Blocks all System.Runtime.Loader library tests from running on Apple mobile platforms:
Recommended action
Option 1: Fix build dependencies (preferred)
Ensure
System.Runtime.Loader.Test.AssemblyandSystem.Runtime.Loader.Test.Assembly2are built (or at least their assembly references are available) before ILLink runs on the main test project. This may require:ProjectReferenceelements inSystem.Runtime.Loader.Tests.csproj(if not already present)RunILLinktargeteng/testing/tests.ioslike.targets, etc.)Option 2: Conditional descriptor inclusion
Exclude the problematic assembly references from the ILLink descriptor on mobile platforms:
However, ILLink descriptor XML does not support MSBuild conditions directly. This would require preprocessing or splitting descriptors.
Option 3: Disable these specific tests on mobile (workaround)
If the tests genuinely depend on dynamic assembly loading features unavailable on trimmed/AOT mobile platforms, exclude the affected test methods with
[SkipOnPlatform]or adjustTargetFrameworksin the csproj. But first verify if that's actually the case — many AssemblyLoadContext tests should work on mobile.Investigation steps
System.Runtime.Loader.Tests.csprojhave<ProjectReference>for the test assembly projects? If not, add them.eng/testing/tests.ioslike.targetsandsrc/mono/msbuild/apple/build/AppleBuild.targetsfor custom dependency handling.iossimulator-x64with verbose MSBuild logging to see the exact dependency resolution and trimming order.Related issues
MarshalModeenumUnmanagedToManagedReturnoption to avoid the analyzer to complainSYSLIB1057about the missing function? #124726 (which tracked a different test assembly dependency problem that was resolved)eng/testing/tests.mobile.targets