This repo contains several implementations of "Hello World" for different .NET platforms. The purpose this exercise is to see how th binary size differs. I wrote up my findings about.NET 6 in a blog post.
All experiments are done on Windows x64. For .NET 6, the relative sizes are in about the same ballpark for Linux and macOS.
For the non .NET Framework versions, the output is generated by running dotnet publish -c release.
If you want a Native AOT Hello World smaller still, see bflat by Michal Strehovský.
While not strictly Hello World, here are the sizes of some GUI programs that display a single empty form.
As of .NET 7, trimming a Windows Forms project is not officially supported. Andrii Kurdiumov has contributed fixes to make to more features of Windows Forms compatable with NativeAOT ( example ) and has a nuget package that fixes more issues. Work is ongoing to add make WinForms fully compatible with NativeAOT.
| Folder | Target Framework | Size (KB) |
|---|---|---|
| 11. Windows Forms | .NET Framework 4.7.2 | 6.5 |
12. dotnet new winforms Self Contained |
.NET SDK 8.0.100-preview.1.23115.2 | 160,296 |
14. dotnet new winforms AOT |
.NET SDK 8.0.100-preview.1.23115.2 NativeAOT | 28,007 |
Note that all these dotnet new winforms examples include some
files related to WPF
as well. If your interested in how you can exclude extra files during
publishing, see my IlLinkerExample repo.
| System | Version | Size (KB) |
|---|---|---|
| Go, following getting started instructions | 1.20.0 | 1,885 |
Rust, doing cargo init && cargo build --release |
1.67.1 | 156 |
| Electron | 13.1.1 | 186,857 |
| Java .JAR file | 0.75 | |
| Graal Native Image | 21.1.0 | 8978 |