-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Optimizing assemblies for size failed" - Core 9 Preview 6 Maui Mac Catalyst Build #104945
Comments
Hi I'm an AI powered bot that finds similar issues based off the issue title. Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you! Open similar issues:
Closed similar issues:
|
Can you create and attach a binlog please? |
msbuild.binlog.zip |
@sbomer - for ideas on why this fails (maybe we should print out the full exception in this case?) |
The binlog shows a stacktrace:
The failure mode looks potentially related to missing references, similar to #93797, but I'll need a repro. I haven't had any success creating a maui app today. @vitek-karas any chance your repro tool would be able to help get us a repro for this? |
@sbomer it feels like the same issue, but really I have very few packages referenced.
I feel like this error is super obscure especially since it doesn't tell me what packages are causing the problem - get_IsDynamicCodeSupported could be used in any given package probably, right? Is there anything in the CSProj I can change to bypass this check? |
@sbomer I figured it out - I hope this helps you. I was referencing Twilio: but when I was trying to narrow down what 3rd party package was causing the problem and commented it out, my app started complaining that System.IdentityModel.Tokens.Jwt couldn't be found (I use JWT for log in the app) - so it seems System.IdentityModel.Tokens.Jwt was being pulled from a reference that Twilio's nuget had.
So I added this reference too, and now the app builds fine. I guess I feel like the error should be pretty verbose in somehow telling me like, hey, you're referencing System.IdentityModel.Tokens.Jwt, but not directly, so that's not cool, bro - instead of this super obscure error. LMK what you think :) Mitch |
Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas |
@caliberdigitalllc thanks for the additional notes. After experimenting a little more with maui and your csproj I was able to get a repro. The error is definitely not by design - the fix should either allow the app to be trimmed even with the missing reference, or produce a better error. I'll investigate and report back soon. |
Turns out this wasn't really about the missing reference. It just so happened that updating to a later version of that reference got rid of a call to IsDynamicCodeCompiled that was causing the problem. This was caused by a bug in the interaction between AggressiveAttributeTrimming, FeatureGuardAttribute, and IL rewriting for constant properties. #104995 has a fix, but we should consider disabling AggressiveAttributeTrimming in maui because that feature isn't really supported. See #88805. It's possible to work around this by setting: <_AggressiveAttributeTrimming>false</_AggressiveAttributeTrimming> |
@sbomer thank you for addressing this :) |
Description
I am trying to build for mac catalyst - this seemed to work in Preview 4 with the same command line, but what I did for that was to clear old preview SDK's out and that fixed it - where as here, all I have is core 8 final and 9 preview 6.
ILLink : error IL1011: Failed to write 'obj/Release/net9.0-maccatalyst/maccatalyst-x64/linked/System.Private.CoreLib.dll'.
/Users/mitch/.nuget/packages/microsoft.net.illink.tasks/9.0.0-preview.6.24327.7/build/Microsoft.NET.ILLink.targets(95,5): error NETSDK1144: Optimizing assemblies for size failed.
AbMobileMaui net9.0-maccatalyst failed with 16 warning(s) (3.8s)
Steps to Reproduce
I am using this command line:
dotnet publish -f net9.0-maccatalyst -c Release
-p:ArchiveOnBuild=true
-p:CreatePackage=true
-p:EnableCodeSigning=true
-p:CodesignKey="Apple Distribution: AlzBetter LLC (8DVSMQ7G8N)"
-p:CodesignProvision="MacOS Distribution"
-p:CodesignEntitlements="Platforms/MacCatalyst/Entitlements.plist"
-p:UseHardenedRuntime=true
Edit: Attaching CSProj as a file due to formatting.
Link to public reproduction project repository
No response
Version with bug
9.0.0-preview.6.24327.7
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
9.0.0-preview.4.10690
Affected platforms
macOS
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: