Native AOT and trimming for document conversion in .NET

Both DocToolkit assemblies are trimmable and the core assembly is AOT-compatible, and CI runs the result. This guide gives the command, what CI proves, and the one warning to expect.

dotnet publish -c Release -r linux-x64 -p:PublishAot=true

What CI proves

  • Both assemblies are marked trimmable, and the core assembly is marked AOT-compatible.
  • CI publishes a probe application, trimmed in one job and native AOT in the other, and asserts that no warning belongs to DocToolkit.
  • Then CI runs the binary. A library that publishes warning-free but crashes on first call would not pass either job.
  • Running it matters because neither trimming nor AOT fails at publish time when it fails: the app throws, or quietly produces an empty document, in production.

The one ClosedXML warning

  • The underlying OOXML libraries use reflection in places.
  • ClosedXML emits one warning, IL2090 in DescribedEnumParser<T>, under both trimming and AOT.
  • Spreadsheet reading and writing work correctly in the published binaries CI runs, but the warning will appear in your own output.

What it will not do

  • If you trim or AOT-publish aggressively and something fails, check the warnings from the OOXML assemblies before suspecting DocToolkit.