DEV Community

Supraja Tangella
Supraja Tangella

Posted on

๐—จ๐—ป๐—น๐—ผ๐—ฐ๐—ธ๐—ถ๐—ป๐—ด ๐—ฃ๐—ฒ๐—ฟ๐—ณ๐—ผ๐—ฟ๐—บ๐—ฎ๐—ป๐—ฐ๐—ฒ: ๐—ช๐—ต๐—ฎ๐˜ ๐—ถ๐˜€ ๐—ก๐—ฎ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—”๐—ข๐—ง ๐—ฎ๐—ป๐—ฑ ๐—›๐—ผ๐˜„ ๐˜๐—ผ ๐—จ๐˜€๐—ฒ ๐—ถ๐˜ ๐—ถ๐—ป ๐—”๐—ฆ๐—ฃ.๐—ก๐—˜๐—ง ๐—–๐—ผ๐—ฟ๐—ฒ ๐—ช๐—ฒ๐—ฏ ๐—”๐—ฝ๐—ฝ๐˜€

๐—ช๐—ต๐—ฎ๐˜ ๐—ถ๐˜€ ๐—ก๐—ฎ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—”๐—ข๐—ง?
Native Ahead-Of-Time (AOT) compilation is a feature in .NET 8 that compiles your application directly to a native executable. This means your app runs without relying on Just-In-Time (JIT) compilation at runtime, resulting in faster startup times and smaller memory footprint.

๐—”๐—ฑ๐˜ƒ๐—ฎ๐—ป๐˜๐—ฎ๐—ด๐—ฒ๐˜€ ๐—ผ๐—ณ ๐—ก๐—ฎ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—”๐—ข๐—ง:

  • ๐—™๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐˜€๐˜๐—ฎ๐—ฟ๐˜๐˜‚๐—ฝ ๐˜๐—ถ๐—บ๐—ฒ because code is precompiled.
  • ๐—ฅ๐—ฒ๐—ฑ๐˜‚๐—ฐ๐—ฒ๐—ฑ ๐—บ๐—ฒ๐—บ๐—ผ๐—ฟ๐˜† ๐˜‚๐˜€๐—ฎ๐—ด๐—ฒ as no JIT compiler is needed at runtime.
  • ๐—ฆ๐—บ๐—ฎ๐—น๐—น๐—ฒ๐—ฟ ๐—ฑ๐—ฒ๐—ฝ๐—น๐—ผ๐˜†๐—บ๐—ฒ๐—ป๐˜ ๐˜€๐—ถ๐˜‡๐—ฒ especially when combined with trimming unused code.
  • ๐—ฆ๐—ฒ๐—น๐—ณ-๐—ฐ๐—ผ๐—ป๐˜๐—ฎ๐—ถ๐—ป๐—ฒ๐—ฑ ๐—ฒ๐˜…๐—ฒ๐—ฐ๐˜‚๐˜๐—ฎ๐—ฏ๐—น๐—ฒ๐˜€ that include the runtime, making deployment simpler.

๐—Ÿ๐—ถ๐—บ๐—ถ๐˜๐—ฎ๐˜๐—ถ๐—ผ๐—ป๐˜€ ๐—ผ๐—ณ ๐—ก๐—ฎ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—”๐—ข๐—ง:

  • Limited support for dynamic features like Reflection.Emit and runtime code generation.
  • Some third-party libraries may not be compatible due to heavy use of reflection or dynamic loading.
  • Requires careful code design to avoid unsupported features.
  • Razor runtime compilation is not supported; views must be precompiled.

๐—›๐—ผ๐˜„ ๐˜๐—ผ ๐—œ๐—บ๐—ฝ๐—น๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—ก๐—ฎ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—”๐—ข๐—ง ๐—ถ๐—ป ๐—”๐—ฆ๐—ฃ.๐—ก๐—˜๐—ง ๐—–๐—ผ๐—ฟ๐—ฒ ๐— ๐—ฉ๐—–:

  1. ๐—จ๐—ฝ๐—ฑ๐—ฎ๐˜๐—ฒ ๐˜†๐—ผ๐˜‚๐—ฟ ๐—ฝ๐—ฟ๐—ผ๐—ท๐—ฒ๐—ฐ๐˜ ๐—ณ๐—ถ๐—น๐—ฒ (.๐—ฐ๐˜€๐—ฝ๐—ฟ๐—ผ๐—ท) to enable Native AOT and trimming:


net8.0
true
true
true
win-x64 <!-- Change as per your platform -->

  1. ๐—ฃ๐˜‚๐—ฏ๐—น๐—ถ๐˜€๐—ต ๐˜๐—ต๐—ฒ ๐—ฝ๐—ฟ๐—ผ๐—ท๐—ฒ๐—ฐ๐˜ with the following command:

dotnet publish -c Release -r win-x64 --self-contained true /p:PublishAot=true

  1. ๐—ฅ๐˜‚๐—ป ๐˜๐—ต๐—ฒ ๐—ด๐—ฒ๐—ป๐—ฒ๐—ฟ๐—ฎ๐˜๐—ฒ๐—ฑ ๐—ป๐—ฎ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฒ๐˜…๐—ฒ๐—ฐ๐˜‚๐˜๐—ฎ๐—ฏ๐—น๐—ฒ from the publish folder.

๐—ฆ๐—ฎ๐—บ๐—ฝ๐—น๐—ฒ .๐—ฐ๐˜€๐—ฝ๐—ฟ๐—ผ๐—ท ๐˜€๐—ป๐—ถ๐—ฝ๐—ฝ๐—ฒ๐˜ ๐—ณ๐—ผ๐—ฟ ๐—ก๐—ฎ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—”๐—ข๐—ง:


net8.0
true
true
true
win-x64

๐—›๐—ฎ๐˜ƒ๐—ฒ ๐˜†๐—ผ๐˜‚ ๐—ฒ๐˜…๐—ฝ๐—ฒ๐—ฟ๐—ถ๐—บ๐—ฒ๐—ป๐˜๐—ฒ๐—ฑ ๐˜„๐—ถ๐˜๐—ต ๐—ก๐—ฎ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—”๐—ข๐—ง ๐—ถ๐—ป ๐˜†๐—ผ๐˜‚๐—ฟ ๐—ฝ๐—ฟ๐—ผ๐—ท๐—ฒ๐—ฐ๐˜๐˜€? ๐—ช๐—ต๐—ฎ๐˜ ๐—ฐ๐—ต๐—ฎ๐—น๐—น๐—ฒ๐—ป๐—ด๐—ฒ๐˜€ ๐—ผ๐—ฟ ๐—ฏ๐—ฒ๐—ป๐—ฒ๐—ณ๐—ถ๐˜๐˜€ ๐—ฑ๐—ถ๐—ฑ ๐˜†๐—ผ๐˜‚ ๐—ผ๐—ฏ๐˜€๐—ฒ๐—ฟ๐˜ƒ๐—ฒ?

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.