Skip to content

[NativeAOT] How to reduce size of published shared library? #524

@Symbai

Description

@Symbai

I was trying out nativeAOT following this guide but I'm using a new empty .NET 5 dll project. The output size were 4.5mb for literally NO code at all.

Then I was trying to add some lines:

<PropertyGroup>
	<IlcDisableReflection>true</IlcDisableReflection>
	<RootAllApplicationAssemblies>false</RootAllApplicationAssemblies>
	<IlcGenerateCompleteTypeMetadata>false</IlcGenerateCompleteTypeMetadata>
	<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>
	<IlcDisableUnhandledExceptionExperience>true</IlcDisableUnhandledExceptionExperience>
	<IlcOptimizationPreference>Size</IlcOptimizationPreference>
</PropertyGroup>

This reduced the size from 4.5mb to 1mb. But imagine that its an empty project, it's still waaaaay too big. With C++ or Pascal I'm within 100kb area.

Is there more I can do to reduce the size or is it expected to be 10 times larger than other AOT compilers?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-NativeAOT-coreclr.NET runtime optimized for ahead of time compilationquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions