cottle icon indicating copy to clipboard operation
cottle copied to clipboard

Question: Support for Native AOT?

Open jonas-stjernquist opened this issue 1 year ago • 2 comments

Does cottle have support for .NET8 and publishing the application with Native AOT?

<PropertyGroup>
    <PublishAot>true</PublishAot>
</PropertyGroup>

If not would it be a suitable future feature in the road map?

https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/?tabs=net7%2Cwindows

jonas-stjernquist avatar Mar 03 '24 21:03 jonas-stjernquist

Hi @jonas-stjernquist, support for Native AOT can unfortunately not be added to the library without some changes to it, mostly because it's incompatible with run-time code generation which Cottle relies on. It's only mandatory when generating native documents though, so maybe a separate version of the library could unlock this feature.

I'll try to look into it but have no ETA yet 🙂

r3c avatar Mar 04 '24 07:03 r3c

So I had another look at the documentation, and I'm not sure I have a perfect solution for this need. Publishing AOT assemblies is likely possible by tweaking compilation parameters rather than modifying .csproj directly, but this option is listed as not being a best practice by Microsoft on their page. Even though, it would mean publishing a modified variant where "native" (emitted) documents wouldn't exist. I guess the performance balance is still positive, but that requires some testing. What worries me most is publishing and maintaining two separate flavors of the library.

Out of curiosity, what is your use case and why would native AOT assembly be a requirement or nice to have?

(in the meantime I'm unlocking net8.0 assemblies because there is no reason for them to be missing, even though it won't solve your issue)

r3c avatar Mar 07 '24 21:03 r3c