Skip to content
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

dotnet publish command fails with error NETSDK1144: Optimizing assemblies for size failed #92064

Closed
YuliaLoyko opened this issue Sep 13, 2023 · 10 comments · Fixed by #92094
Closed
Assignees
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers
Milestone

Comments

@YuliaLoyko
Copy link

I'm running the following command to build maui ios project

dotnet publish .ProjectName.csproj -c Staging -f net7.0-ios -p:ApplicationDisplayVersion=3.0.0 -p:ApplicationVersion=3.0.0.123 -p:ArchiveOnBuild=true -p:RuntimeIdentifier=ios-arm64 -p:CodesignKey="Apple Distribution: <title is here>" -p:MtouchLink=SdkOnly

It fails with

/usr/local/share/dotnet/sdk/7.0.306/Sdks/Microsoft.NET.ILLink.Tasks/build/Microsoft.NET.ILLink.targets(86,5): error NETSDK1144: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false

I'm not able to provide a detailed log because the project is under NDA, but can give any other details regarding the libraries usage, etc.

@marek-safar
Copy link
Contributor

Any chance to try to run it with .NET8 RC1 candidate?

@awasilik
Copy link

awasilik commented Sep 14, 2023

Hey, I encountered same problem in my project for .net8 (wasn't there for .net7 though). I described it here:
#91880

@YuliaLoyko
Copy link
Author

hey @awasilik
in my case building with -p:MtouchLink=None solves the issue, but i can't publish such app because as far as libraries code is not trimmed - apple thinks we are using a lot of APIs we're not using and requires to add reasons to info plist and entitlements

@YuliaLoyko
Copy link
Author

@marek-safar i'll try when configure my environment for it

@YuliaLoyko
Copy link
Author

actually @marek-safar i've tried with net8 and the issue persists

@marek-safar
Copy link
Contributor

Do you see same stack trace in your msbuild log as in #91880 or is it different?

@YuliaLoyko
Copy link
Author

YuliaLoyko commented Sep 14, 2023

it is different

it shows about 3000 lines of same traces

Stack overflow. (TaskId:200)
                        at Mono.Linker.DynamicallyAccessedMembersBinder+<GetDynamicallyAccessedMembers>d__0.MoveNext() (TaskId:200)
                        at Mono.Linker.Dataflow.ReflectionMarker.MarkTypeForDynamicallyAccessedMembers(Mono.Linker.MessageOrigin ByRef, Mono.Cecil.TypeDefinition, System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, Mono.Linker.DependencyKind, Boolean) (TaskId:200)
                        at ILLink.Shared.TrimAnalysis.RequireDynamicallyAccessedMembersAction.MarkTypeForDynamicallyAccessedMembers(ILLink.Shared.TypeSystemProxy.TypeProxy ByRef, System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes) (TaskId:200)
                        at ILLink.Shared.TrimAnalysis.RequireDynamicallyAccessedMembersAction.Invoke(ILLink.Shared.DataFlow.ValueSet``1<ILLink.Shared.DataFlow.SingleValue> ByRef, ILLink.Shared.TrimAnalysis.ValueWithDynamicallyAccessedMembers) (TaskId:200)
                        at Mono.Linker.Dataflow.AttributeDataFlow.RequireDynamicallyAccessedMembers(ILLink.Shared.TrimAnalysis.DiagnosticContext ByRef, ILLink.Shared.DataFlow.ValueSet``1<ILLink.Shared.DataFlow.SingleValue> ByRef, ILLink.Shared.TrimAnalysis.ValueWithDynamicallyAccessedMembers) (TaskId:200)
                        at Mono.Linker.Dataflow.AttributeDataFlow.ProcessAttributeDataflow(Mono.Cecil.MethodDefinition, System.Collections.Generic.IList``1<Mono.Cecil.CustomAttributeArgument>) (TaskId:200)
                        at Mono.Linker.Steps.MarkStep.MarkCustomAttributeProperty(Mono.Cecil.CustomAttributeNamedArgument, Mono.Cecil.TypeDefinition, Mono.Cecil.ICustomAttribute, Mono.Linker.DependencyInfo ByRef) (TaskId:200)
                        at Mono.Linker.Steps.MarkStep.MarkCustomAttributeProperties(Mono.Cecil.ICustomAttribute, Mono.Cecil.TypeDefinition) (TaskId:200)
                        at Mono.Linker.Steps.MarkStep.MarkCustomAttribute(Mono.Cecil.CustomAttribute, Mono.Linker.DependencyInfo ByRef) (TaskId:200)
                        at Mono.Linker.Steps.MarkStep.MarkCustomAttributes(Mono.Cecil.ICustomAttributeProvider, Mono.Linker.DependencyInfo ByRef) (TaskId:200)
                        at Mono.Linker.Steps.MarkStep.MarkProperty(Mono.Cecil.PropertyDefinition, Mono.Linker.DependencyInfo ByRef) (TaskId:200)
                        at Mono.Linker.Steps.MarkStep.MarkPropertyVisibleToReflection(Mono.Cecil.PropertyDefinition, Mono.Linker.DependencyInfo ByRef, Mono.Linker.MessageOrigin ByRef) (TaskId:200)
                        at Mono.Linker.Dataflow.ReflectionMarker.MarkProperty(Mono.Linker.MessageOrigin ByRef, Mono.Cecil.PropertyDefinition, Mono.Linker.DependencyKind) (TaskId:200)
                        at Mono.Linker.Dataflow.ReflectionMarker.MarkTypeForDynamicallyAccessedMembers(Mono.Linker.MessageOrigin ByRef, Mono.Cecil.TypeDefinition, System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, Mono.Linker.DependencyKind, Boolean) (TaskId:200)
                        at ILLink.Shared.TrimAnalysis.RequireDynamicallyAccessedMembersAction.MarkTypeForDynamicallyAccessedMembers(ILLink.Shared.TypeSystemProxy.TypeProxy ByRef, System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes) (TaskId:200)
                        at ILLink.Shared.TrimAnalysis.RequireDynamicallyAccessedMembersAction.Invoke(ILLink.Shared.DataFlow.ValueSet``1<ILLink.Shared.DataFlow.SingleValue> ByRef, ILLink.Shared.TrimAnalysis.ValueWithDynamicallyAccessedMembers) (TaskId:200)
                        at Mono.Linker.Dataflow.AttributeDataFlow.RequireDynamicallyAccessedMembers(ILLink.Shared.TrimAnalysis.DiagnosticContext ByRef, ILLink.Shared.DataFlow.ValueSet``1<ILLink.Shared.DataFlow.SingleValue> ByRef, ILLink.Shared.TrimAnalysis.ValueWithDynamicallyAccessedMembers) (TaskId:200)
                        at Mono.Linker.Dataflow.AttributeDataFlow.ProcessAttributeDataflow(Mono.Cecil.MethodDefinition, System.Collections.Generic.IList``1<Mono.Cecil.CustomAttributeArgument>) (TaskId:200)
                        at Mono.Linker.Steps.MarkStep.MarkCustomAttributeProperty(Mono.Cecil.CustomAttributeNamedArgument, Mono.Cecil.TypeDefinition, Mono.Cecil.ICustomAttribute, Mono.Linker.DependencyInfo ByRef) (TaskId:200)
                        at Mono.Linker.Steps.MarkStep.MarkCustomAttributeProperties(Mono.Cecil.ICustomAttribute, Mono.Cecil.TypeDefinition) (TaskId:200)
                        at Mono.Linker.Steps.MarkStep.MarkCustomAttribute(Mono.Cecil.CustomAttribute, Mono.Linker.DependencyInfo ByRef) (TaskId:200)
                        at Mono.Linker.Steps.MarkStep.MarkCustomAttributes(Mono.Cecil.ICustomAttributeProvider, Mono.Linker.DependencyInfo ByRef) (TaskId:200)
                        at Mono.Linker.Steps.MarkStep.MarkProperty(Mono.Cecil.PropertyDefinition, Mono.Linker.DependencyInfo ByRef) (TaskId:200)
                        at Mono.Linker.Steps.MarkStep.MarkPropertyVisibleToReflection(Mono.Cecil.PropertyDefinition, Mono.Linker.DependencyInfo ByRef, Mono.Linker.MessageOrigin ByRef) (TaskId:200)
                        at Mono.Linker.Dataflow.ReflectionMarker.MarkProperty(Mono.Linker.MessageOrigin ByRef, Mono.Cecil.PropertyDefinition, Mono.Linker.DependencyKind) (TaskId:200)
                        at Mono.Linker.Dataflow.ReflectionMarker.MarkTypeForDynamicallyAccessedMembers(Mono.Linker.MessageOrigin ByRef, Mono.Cecil.TypeDefinition, System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, Mono.Linker.DependencyKind, Boolean) (TaskId:200)
                        at ILLink.Shared.TrimAnalysis.RequireDynamicallyAccessedMembersAction.MarkTypeForDynamicallyAccessedMembers(ILLink.Shared.TypeSystemProxy.TypeProxy ByRef, System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes) (TaskId:200)
                        at ILLink.Shared.TrimAnalysis.RequireDynamicallyAccessedMembersAction.Invoke(ILLink.Shared.DataFlow.ValueSet``1<ILLink.Shared.DataFlow.SingleValue> ByRef, ILLink.Shared.TrimAnalysis.ValueWithDynamicallyAccessedMembers) (TaskId:200)`

@marek-safar
Copy link
Contributor

@vitek-karas is this the stack trace enough for you to see what is wrong?

@marek-safar marek-safar transferred this issue from dotnet/linker Sep 14, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Sep 14, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Sep 14, 2023
@marek-safar marek-safar added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Sep 14, 2023
@ghost
Copy link

ghost commented Sep 14, 2023

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
See info in area-owners.md if you want to be subscribed.

Issue Details

I'm running the following command to build maui ios project

dotnet publish .ProjectName.csproj -c Staging -f net7.0-ios -p:ApplicationDisplayVersion=3.0.0 -p:ApplicationVersion=3.0.0.123 -p:ArchiveOnBuild=true -p:RuntimeIdentifier=ios-arm64 -p:CodesignKey="Apple Distribution: <title is here>" -p:MtouchLink=SdkOnly

It fails with

/usr/local/share/dotnet/sdk/7.0.306/Sdks/Microsoft.NET.ILLink.Tasks/build/Microsoft.NET.ILLink.targets(86,5): error NETSDK1144: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false

I'm not able to provide a detailed log because the project is under NDA, but can give any other details regarding the libraries usage, etc.

Author: YuliaLoyko
Assignees: -
Labels:

untriaged, area-Tools-ILLink, needs-area-label

Milestone: -

@marek-safar marek-safar removed untriaged New issue has not been triaged by the area owner needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Sep 14, 2023
@marek-safar marek-safar added this to the 8.0.0 milestone Sep 14, 2023
@sbomer
Copy link
Member

sbomer commented Sep 14, 2023

I can reproduce this with a testcase like the following:

		class RecursivePropertyDataFlow
		{
			class AttributePropertyRequiresPropertiesAttribute : Attribute
			{
				[AttributePropertyRequiresProperties (RequiresPublicProperties = typeof (AttributePropertyRequiresPropertiesAttribute))]
				[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)]
				public Type RequiresPublicProperties { get; set; }
			}

			[AttributePropertyRequiresProperties (RequiresPublicProperties = typeof (int))]
			public static void Test ()
			{
			}
		}

@sbomer sbomer self-assigned this Sep 14, 2023
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Sep 14, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Sep 15, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Oct 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants