Table of Contents
Introduction
Application startup time is a critical metric for user experience. With .NET 8, several new features and optimizations can dramatically reduce the time it takes for an app to become responsive. This post walks through practical steps you can take to shave off valuable milliseconds.
Benchmarks
Below are results from a simple console app built with dotnet new console using various configurations.
# Baseline (Debug)
dotnet run --configuration Debug
# => Startup: 820 ms
# Release (no trimming)
dotnet run --configuration Release
# => Startup: 380 ms
# Release + PublishTrimmed
dotnet publish -c Release -p:PublishTrimmed=true
# => Startup: 240 ms
Techniques
- ReadyToRun (R2R) – Pre‑compiles IL to native code.
- Trimmed Publishing – Removes unused assemblies.
- Single‑File Executables – Reduces I/O overhead.
- Tiered Compilation – Defers heavy optimizations until after warm‑up.
- Native AOT – Generates a truly native binary.
Sample Code
Use the following csproj snippet to enable the recommended settings.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<PublishTrimmed>true</PublishTrimmed>
<PublishReadyToRun>true</PublishReadyToRun>
<SelfContained>true</SelfContained>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>
</Project>
Conclusion
By combining trimming, ReadyToRun, and single‑file publishing, most .NET apps can achieve sub‑200 ms startup times on modern hardware. Evaluate the trade‑offs (size vs. performance) for your specific scenario, and profile with dotnet-trace or BenchmarkDotNet to confirm the impact.