Summary
Building an app with PrepareAssemblies=true (the assembly-preparer) and link mode "all" (MtouchLink=Full / TrimMode=full) fails during ILLink with:
error IL2036: ..cctor(): Unresolved type 'Foundation.NSExpression' in 'DynamicDependencyAttribute'.
error NETSDK1144: Optimizing assemblies for size failed.
The assembly-preparer adds a [DynamicDependency] attribute (on the module ..cctor) referencing Foundation.NSExpression, but ILLink then trims NSExpression away in full-link mode, leaving the dependency dangling → IL2036 → the trimmer aborts with NETSDK1144.
Steps to reproduce
Build monotouch-test for iOS with link all + PrepareAssemblies:
tests-monotouch ios --variations='release|linkall' --build-arguments='/p:PrepareAssemblies=true /p:PostProcessAssemblies=true'
or directly:
dotnet build tests/monotouch-test/dotnet/iOS/monotouch-test.csproj -c Release \
-p:RuntimeIdentifier=iossimulator-arm64 -p:UseFloatingTargetPlatformVersion=true \
-p:MtouchLink=Full -p:UseMonoRuntime=true \
-p:PrepareAssemblies=true -p:PostProcessAssemblies=true
Actual result
The build fails:
..cctor(): Unresolved type 'Foundation.NSExpression' in 'DynamicDependencyAttribute'. (IL2036)
Optimizing assemblies for size failed. (NETSDK1144)
Expected result
The build succeeds, as it does with MtouchLink=SdkOnly and with link None.
Additional context
- Reproduces on
main (commit 8111cb6c59) — this is not a regression from any in-flight assembly-preparer change.
release|linksdk (SdkOnly) + PrepareAssemblies, and link None + PrepareAssemblies, both build and pass monotouch-test (3675 tests, 0 failed).
- A trivial app (
MySimpleApp) with MtouchLink=Full + PrepareAssemblies builds fine — the failure only shows up with a larger app (monotouch-test).
Summary
Building an app with
PrepareAssemblies=true(the assembly-preparer) and link mode "all" (MtouchLink=Full/TrimMode=full) fails during ILLink with:The assembly-preparer adds a
[DynamicDependency]attribute (on the module..cctor ) referencingFoundation.NSExpression, but ILLink then trimsNSExpressionaway in full-link mode, leaving the dependency dangling →IL2036→ the trimmer aborts withNETSDK1144.Steps to reproduce
Build monotouch-test for iOS with link all + PrepareAssemblies:
or directly:
Actual result
The build fails:
Expected result
The build succeeds, as it does with
MtouchLink=SdkOnlyand with link None.Additional context
main(commit8111cb6c59) — this is not a regression from any in-flight assembly-preparer change.release|linksdk(SdkOnly) + PrepareAssemblies, and link None + PrepareAssemblies, both build and pass monotouch-test (3675 tests, 0 failed).MySimpleApp) withMtouchLink=Full+ PrepareAssemblies builds fine — the failure only shows up with a larger app (monotouch-test).