Skip to content

IsPortableCodeView false in stripped assemblies on iOS #118700

Closed

Description

@jamescrosswell

Apple platform

iOS

Framework version

net9.0-*

Affected platform version

net9.0-ios18.0 version 9.0.301 (workload version 9.0.301 also)

Description

When building a .NET 9 MAUI application targeting iOS in release mode, IsPortableCodeView should be true in the CodeView debug directory entry. It appears to incorrectly return false since the MinorVersion is set to 0.

Steps to Reproduce

Clone https://github.com/jamescrosswell/is-portable and follow the instructions in the readme.

Expected behaviour

IsPortableCodeView should be true for all of the assemblies. This should only be false for Windows PDB files (not relevant when running on iOS).

Actual behaviour

IsPortableCodeView is showing as false for the PE file located at MauiTestApp/obj/Release/net9.0-ios/iossimulator-arm64/stripped/MauiTestApp.dll. This is problematic since this appears to be the assembly that is actually used when running the app on the iOS simulator (where we're also observing this issue in the Sentry SDK for .NET).

Additionally the value of the Stamp differs from the Stamp in the accompanying PDB files (meaning symbolication is no longer possible).

Did you find any workaround?

Building with /p:MtouchLink=SdkOnly avoids the issue for application assemblies. This isn't really a workaround though. In the case of Sentry, that means we still won't be able to symbolicate stack frames from the SDK and may increase the size of our SDK users's applications when shipping these.

Relevant log output

No response

Activity

  1. rolfbjarne commented on Aug 13, 2025

    @rolfbjarne
    Member

    Setting EnableAssemblyILStripping=false in the csproj works around this, so it looks like it's a problem with the IL stripper (the ILStrip task) => moving to dotnet/runtime.

  2. transferred this issue fromdotnet/macioson Aug 13, 2025
  3. added
    untriaged
    on Aug 13, 2025
  4. added
    needs-area-label
    on Aug 13, 2025
  5. added and removed
    needs-area-label
    on Aug 13, 2025
  6. akoeplinger commented on Aug 14, 2025

    @akoeplinger
    Member

    Ah interesting. This sounds like it's a problem in the (very old) special copy of Cecil we use in the ILStrip task that we can't upgrade for various reasons and moving to System.Reflection.Metadata has been on the backlog for quite some time (dotnet/runtime-assets#383)

    We'd probably need to backport whatever fixes this to https://github.com/dotnet/runtime-assets/tree/main/src/Microsoft.DotNet.CilStrip.Sources, but this definitely won't make it into 10.0

    @jamescrosswell if you want to work on this feel free to ping me on Discord and I can give more background.

  7. removed
    untriaged
    on Aug 14, 2025
  8. added this to the 11.0.0 milestone on Aug 14, 2025
  9. jamescrosswell commented on Aug 21, 2025

    @jamescrosswell
    Author

    It's curious that this only started happening recently. I know the Age/Stamp in the PE Header matched those in the PDB for net9.0-ios apps built in release mode in the past... So something about how stripping is performed has changed recently.

    It looks like the last change to the Cecil sources was August 2024 😕

    There are more recent changes to the ILStrip task, but none that I can see that seem like they would cause a change in this behaviour.

  10. akoeplinger commented on Aug 26, 2025

    @akoeplinger
    Member

    It's curious that this only started happening recently.

    Hmm yeah that's strange since I can't see any change in that area either. Maybe confirm by installing an earlier build of net9 and the iOS workload.

  11. maexsp commented on Nov 24, 2025

    @maexsp

    This is still a major problem specially when using E.g. Sentry Analytics for iOS.
    Setting <MtouchLink>SdkOnly</MtouchLink> does not solve the problem in our case when publishing iOS Release Builds.

    Alternative workaround to set <EnableAssemblyILStripping>false</EnableAssemblyILStripping> increases our app from 55MB to 175MB affecting all our end users. Not something we can give a go.

    @rolfbjarne Any updates on this or alternative options?

  12. rolfbjarne commented on Nov 27, 2025

    @rolfbjarne
    Member

    @rolfbjarne Any updates on this or alternative options?

    AFAIK no work has been done here, nor do I know of any workaround unfortunately (except something extreme like adding a custom MSBuild target that modifies the assemblies in question just before the app is signed).

  13. jamescrosswell commented on Dec 10, 2025

    @jamescrosswell
    Author

    It's curious that this only started happening recently.

    Hmm yeah that's strange since I can't see any change in that area either. Maybe confirm by installing an earlier build of net9 and the iOS workload.

    Maybe I was wrong about this. I just tried with SDK and workload versions 9.0.100 and see the same behaviour... so worth exploring the theory @akoeplinger had above.

  14. lateralusX commented on Jul 30, 2026

    @lateralusX
    Member

    @akoeplinger, located the issue and the fix is in dotnet/runtime-assets#688. This is a long standing issue or at least as long as we used the cecil binary writer from runtime-assets. It didn't correctly handle the Minor/MajorVersion and timestamp for the portable scenario.

  15. added
    blocked
    on Jul 30, 2026
  16. lateralusX commented on Aug 4, 2026

    @lateralusX
    Member

    Fixed by #131516.

  17. added
    in-pr
    on Aug 4, 2026
  18. jamescrosswell commented on Aug 4, 2026

    @jamescrosswell
    Author

    Fixed by #131516.

    You're a super star @lateralusX - thank you so much ❤️

  19. lateralusX commented on Aug 5, 2026

    @lateralusX
    Member

    Verified using a local build of AssemblyStripper after #131516 merged.

  20. yaliashkevich commented on Sep 4, 2026

    @yaliashkevich

    @rolfbjarne any chance this fix can get included into dotnet 10 ios workload? Latest one 26.5.10315 don't have it.

  21. akoeplinger commented on Sep 4, 2026

    @akoeplinger
    Member

    @yaliashkevich the fix got backported to 10.0 already so it should be part of the next release

  22. locked and limited conversation to collaborators on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-VM-meta-monoblockedin-pr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions