From 835143d95f21c3b3bcaeff61bd759c878c8b8295 Mon Sep 17 00:00:00 2001 From: Phil Scott Date: Thu, 21 Nov 2024 22:14:03 -0500 Subject: [PATCH] Add Native AOT support documentation and update project files for AOT compatibility --- docs/input/best-practices.md | 25 +++++++++++++++++++ .../Spectre.Console.ImageSharp.csproj | 5 +++- .../Spectre.Console.Json.csproj | 7 ++++-- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/docs/input/best-practices.md b/docs/input/best-practices.md index 20dc867..dee4c2d 100644 --- a/docs/input/best-practices.md +++ b/docs/input/best-practices.md @@ -96,6 +96,31 @@ Spectre.Console has an [analyzer](https://www.nuget.org/packages/Spectre.Console common errors in writing console output from above such as using multiple live rendering widgets simultaneously, or using the static `AnsiConsole` class when `IAnsiConsole` is available. +### Native AOT Support + +Publishing your app as Native AOT with Spectre.Console produces an app that's self-contained and has been ahead-of-time (AOT) compiled to native code. Native AOT apps have faster startup time and smaller memory footprints. These apps can run on machines that don't have the .NET runtime installed. + +To enable AOT support on your application, Add `true` to your project file. + +```xml + + true + +``` + +Current Spectre.Console support for AOT: + +* ☑️ Spectre.Console +* ❌ Spectre.Console.Cli +* ☑️ Spectre.Console.Json +* ☑️ Spectre.Console.ImageSharp + +Spectre.Console.Cli relies on reflection and discovering types at runtime, preventing it from currently supporting AOT. + +Spectre.Console supports AOT, but with the following limitations + +* `WriteException` will output a simple stacktrace and ignore any `ExceptionFormats` set. + ### Configuring the Windows Terminal For Unicode and Emoji Support Windows Terminal supports Unicode and Emoji. However, the shells such as Powershell and cmd.exe do not. diff --git a/src/Extensions/Spectre.Console.ImageSharp/Spectre.Console.ImageSharp.csproj b/src/Extensions/Spectre.Console.ImageSharp/Spectre.Console.ImageSharp.csproj index 61c4de2..fff5997 100644 --- a/src/Extensions/Spectre.Console.ImageSharp/Spectre.Console.ImageSharp.csproj +++ b/src/Extensions/Spectre.Console.ImageSharp/Spectre.Console.ImageSharp.csproj @@ -5,7 +5,10 @@ true A library that extends Spectre.Console with ImageSharp superpowers. - + + true + true + diff --git a/src/Extensions/Spectre.Console.Json/Spectre.Console.Json.csproj b/src/Extensions/Spectre.Console.Json/Spectre.Console.Json.csproj index ef09838..6c43198 100644 --- a/src/Extensions/Spectre.Console.Json/Spectre.Console.Json.csproj +++ b/src/Extensions/Spectre.Console.Json/Spectre.Console.Json.csproj @@ -1,12 +1,15 @@ - net9.0;net8.0;netstandard2.0 + net9.0;net8.0;netstandard2.0 true true A library that extends Spectre.Console with JSON superpowers. - + + true + true +