You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IsPortableCodeView false in stripped assemblies on iOS #118700
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.
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
Reacted by Gustaf Järgren, Alexander Hardwicke, J-P Nurmi, Tibo, Kacper Tryniecki, maexsp, IX-OmkarP, H-E-Opter, Pierre Galaup, JC Snider and 9 more
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.
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)
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.
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?
@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).
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.
@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.
Activity
rolfbjarne commentedon Aug 13, 2025
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.
akoeplinger commentedon Aug 14, 2025
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.
jamescrosswell commentedon Aug 21, 2025
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.
akoeplinger commentedon Aug 26, 2025
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.
maexsp commentedon Nov 24, 2025
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?
rolfbjarne commentedon Nov 27, 2025
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).
jamescrosswell commentedon Dec 10, 2025
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.
lateralusX commentedon Jul 30, 2026
@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.
lateralusX commentedon Aug 4, 2026
Fixed by #131516.
Fix IsPortableCodeView when rewriting assembly. (#693)
jamescrosswell commentedon Aug 4, 2026
You're a super star @lateralusX - thank you so much ❤️
lateralusX commentedon Aug 5, 2026
Verified using a local build of AssemblyStripper after #131516 merged.
yaliashkevich commentedon Sep 4, 2026
@rolfbjarne any chance this fix can get included into dotnet 10 ios workload? Latest one 26.5.10315 don't have it.
akoeplinger commentedon Sep 4, 2026
@yaliashkevich the fix got backported to 10.0 already so it should be part of the next release