-
-
Notifications
You must be signed in to change notification settings - Fork 458
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 #1332
Comments
FYI I used the following to get this project to work with AOT: Create some file (e.g. MyRoots.xml) with the following content (substitute MyAssembly with your assembly name): <linker>
<assembly fullname="MyAssembly" />
<assembly fullname="Spectre.Console.Cli">
<type fullname="Spectre.Console.Cli.ExplainCommand" />
<type fullname="Spectre.Console.Cli.XmlDocCommand" />
<type fullname="Spectre.Console.Cli.VersionCommand" />
</assembly>
</linker> This makes sure that all the reflected commands needed don't get trimmed out. Then make use of it in your csproj: <ItemGroup>
<TrimmerRootDescriptor Include="MyRoots.xml" />
</ItemGroup> |
Hmm.... things seemed to be working for me. I was just interested in cleaning up the warnings, but your answer now makes me wonder if some things are broken that i didn't catch. I'll have to take another look |
The project I am working on is here on GitHub so if you are interested in seeing if you see what I see then I can push what I discovered up into the repo (https://github.com/borrrden/Spectre.Net). Coincidentally the project started as a port of a separate unrelated project also called Spectre and then I remembered that this repo existed and thought it was poetic. |
There are still a few more issues I am having with AOT:
|
An alternative to the xml file mentioned by @borrrden that worked for me is to use the [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(DiffCommand))]
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(DiffCommandSettings))]
[DynamicDependency(DynamicallyAccessedMemberTypes.All, "Spectre.Console.Cli.ExplainCommand", "Spectre.Console.Cli")]
[DynamicDependency(DynamicallyAccessedMemberTypes.All, "Spectre.Console.Cli.VersionCommand", "Spectre.Console.Cli")]
[DynamicDependency(DynamicallyAccessedMemberTypes.All, "Spectre.Console.Cli.XmlDocCommand", "Spectre.Console.Cli")]
private static int Main(string[] args)
{
} |
@andwi Would you happen to know anything about my enum situation? 😄 |
Sorry no, my application has not used any enum values so I have not encountered that |
build using `dotnet publish -r linux-amd64 -c Release` test with `bin/Release/net8.0/linux-x64/fsharp-spectre-console-template greet -n John` based on spectreconsole/spectre.console#1332 (comment)
I use CommandApp and AppSettings in my application.
and it seems to work just fine, however, I get the following warnings.
|
Is your feature request related to a problem? Please describe.
This library actually works in the context of native code generation (AOT), but it produces a compiler warning (which makes me suspect there are some features in this library that would not work from an AOT perspective.
Describe the solution you'd like
Would love to see this library run cleanly in an AOT build (AOT seems like a primary candidate for a library like this to create multi-platform commandline tools that do not rely on the dotnet framework being installed.
Describe alternatives you've considered
None
Additional context
Please upvote 👍 this issue if you are interested in it.
The text was updated successfully, but these errors were encountered: