Closed jkotas closed 2 years ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
cc @MichalStrehovsky @agocke
Noting that TerraFX.Interop.Windows is opting into trimming support here: https://github.com/terrafx/terrafx.interop.windows/blob/main/Directory.Build.targets#L23-L32
If you clone the repo and do dotnet publish -c Release -f net6.0-windows -r win-x64 --self-contained
in <repo-root>\samples\DirectX
you'll get:
.\bin\samples\TerraFX.Samples.DirectX\Release\net6.0-windows\TerraFX.Interop.Windows.dll
which is 16,231 KB
.\bin\samples\TerraFX.Samples.DirectX\Release\net6.0-windows\win-x64\publish\TerraFX.Interop.Windows.dll
which is 104 KB
If there is something I'm missing for NAOT support, I'm happy to add it. But AFAIK, I'm following all the documented bits required.
The fix is available on nightly feed now.
The final binary is 36MB. It includes code and metadata for all types in TerraFx.Interop.Windows.
The binary is <5MB now. However, there is still minor size inefficiency. Opened #66716.
Repro (this is slightly modified repro from https://github.com/dotnet/runtime/issues/66545):
.csproj:
Actual result:
The final binary is 36MB. It includes code and metadata for all types in TerraFx.Interop.Windows.
Expected result:
The final binary is <10MB. It only includes code and metadata for types that are actually used by the program.
Publishing with regular IL trimming using IL linker does not have this issue.