Skip to content

[assembly-preparer] PrepareAssemblies + link all (Full trim) fails: IL2036 Unresolved type 'Foundation.NSExpression' in DynamicDependencyAttribute #26017

Description

@rolfbjarne

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions