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 support? #897

Closed
bertt opened this issue Aug 8, 2023 · 2 comments
Closed

Aot support? #897

bertt opened this issue Aug 8, 2023 · 2 comments

Comments

@bertt
Copy link

bertt commented Aug 8, 2023

Hi, I'm trying to use this library with AOT (PublishAot = true) in .NET 8, but got the following warnings on publish (CommandLineParser 2.9.1):

 Generating native code
CommandLine.dll : warning IL2104: Assembly 'CommandLine' produced trim warnings. For more
 information see https://aka.ms/dotnet-illink/libraries
CommandLine.dll : warning IL3053: Assembly 'CommandLine' produced AOT analysis warnings.

And when running I see:

Unhandled Exception: System.InvalidOperationException: Type Options appears to be immutable, but no constructor found to accept values.

Type options:

public class Options
{
    private readonly bool verbose;

    public Options(bool verbose)
    {
        this.verbose = verbose;
    }
    [Option]
    public bool Verbose { get { return verbose; } }
}

Question: Is publishing with AOT supported?

@bertt
Copy link
Author

bertt commented Aug 9, 2023

found a workaround adding

[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(Options))]
static void Main(string[] args)

@bertt bertt closed this as completed Aug 9, 2023
@kgamecarter
Copy link

kgamecarter commented May 12, 2024

#913
NativeAoT in This PR work fine.
And smaller exe size.

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

2 participants