Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AoT compilation doesn't work well #133

Open
PhotoAtomic opened this issue Mar 12, 2024 · 3 comments
Open

AoT compilation doesn't work well #133

PhotoAtomic opened this issue Mar 12, 2024 · 3 comments

Comments

@PhotoAtomic
Copy link

PhotoAtomic commented Mar 12, 2024

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?

@Adwelean
Copy link

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.

@Simonl9l
Copy link

Simonl9l commented Sep 2, 2024

Seems there is an initial open pull request here - #151

@naratteu
Copy link

naratteu commented Sep 3, 2024

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:
naratteu/HexRR@2cdee4d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants