Skip to content

AOT Compiling

ITAgnesmeyer edited this page Apr 25, 2024 · 1 revision

Why AOT compilation?

AOT compilation offers various advantages. Especially with the CoreWindowsWrapper DLL.

Although it is now possible to compile WinForms applications with AOT, the resulting EXE files are extremely large. A small exe compiled with CoreWindowsWrapper, without any other dependencies, produces EXE files between 3MB to 5MB. The last test with WinForms showed a file size of 30MB to 50MB.

Even WebView2 is now possible with CoreWindowsWrapper. See the example “ConsoleCaller”->“BrowserWindow”. (The packages used are still in preview).

Add the PublishAot switch in the project:

 <PropertyGroup>
   <OutputType>WinExe</OutputType>
   <TargetFramework>net8.0</TargetFramework>
   <ImplicitUsings>enable</ImplicitUsings>
   <Nullable>disable</Nullable>
   <PublishAot>true</PublishAot>
   <InvariantGlobalization>true</InvariantGlobalization>
   <Win32Resource>app.res</Win32Resource>
 </PropertyGroup>
Clone this wiki locally