Cocona icon indicating copy to clipboard operation
Cocona copied to clipboard

AoT compilation doesn't work well

Open PhotoAtomic opened this issue 1 year ago • 3 comments

i've tryed to compile my .net 8.0 project with the <PublishAot>true</PublishAot> directive but it not works COCONA appears to be stuck if i compile AoT and doesn't parse the arguments i've tryed also <IsTrimmable>false</IsTrimmable> no luck either i've also tryed

	<ItemGroup>
		<!-- Specify assemblies to prevent from trimming -->
		<TrimmerRootAssembly Include="Cocona" />
		<TrimmerRootAssembly Include="Cocona.Core" />
	</ItemGroup>

as the publish output says

2>Assembly 'Cocona' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries 2>Assembly 'Cocona.Core' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries 2>Assembly 'Cocona.Core' produced AOT analysis warnings.

now the things changes, cocona appear to start but it doesn't understand the command i provide

is there a way to make cocona work with AoT compilation? usually command line tools are quite small, AoT will help a lot in that scneario

in particular, it is probably the trim feature that causes cocona to not work, but it is difficult to tell without a serius investigation of the source code, Do anyone have any successful experience in AoT + Trim compilation?

PhotoAtomic avatar Mar 12 '24 15:03 PhotoAtomic

I have the same problem, here's what I managed to find while playing with a debugger :

A suitable constructor for type 'Cocona.Command.Dispatcher.Middlewares.InitializeConsoleAppMiddleware' could not be located. Ensure the type is concrete and all parameters of a public constructor are either registered as services or passed as arguments. Also ensure no extraneous arguments are provided.

Adwelean avatar Jun 10 '24 10:06 Adwelean

Seems there is an initial open pull request here - https://github.com/mayuki/Cocona/pull/151

Simonl9l avatar Sep 02 '24 17:09 Simonl9l

I have experience building simple AOT applications that reference DragonFruit and Cocona. For Cocona, you must specify trimming exclusions for the public constructor as shown in the error log.

Check out the application code below: https://github.com/naratteu/HexRR/commit/2cdee4db4ba7fb3bc217ab7ee4a365a526487627

naratteu avatar Sep 03 '24 06:09 naratteu