❔ Distributing a CLI app (with .NET 8 Native AOT)
Hi guys, I built a CLI app that I'd like to distribute to the major platforms (windows, mac, linux). I'm trying to deal with building and distributing the app now that I have a version that I'm happy with, though I'm running into some issues..
I thought that with .NET 8's improved Native AOT, it'd be perfect to write my app targeting that. The app's use is that it makes it easy to create files and directories etc. so I honestly don't think a self-contained app is suitable for this use-case because how can I ask people to install 100MB+ for such a simple app (though maybe I can)?
I'm using
CommandLineParser
for dealing with the argument parsing, and using DotNetYaml
in also a relatively critical part of the app, both are throwing Native AOT warnings and Trim warnings.
The app crashes when creating the Options object from CommandLineParser.Parser.ParseArguments
.. (this doesn't happen when running it locally with the debugger attached, only when running the executable that was built with Native AOT with dotnet publish
)
The exception I'm currently hitting reads as follows:
It honestly seems quite a lot like it's coming from the Trim and/or AOT warnings when building the project.
There's a few questions I'd like to ask:
1. Any advice on how I can deal with the exception?
2. Is it even worth it for me to dig into this issue? There may be plenty more even if I solve the one I'm currently encountering
3. Am I overreacting regarding size? I guess I could just release a self-contained app but like I mentioned above, I feel like the size is too big to justify the use-case
4. Any tips or examples on proper open-source CLI apps built on .net? I'm honestly quite lost especially regarding distributing them but I'm also starting to think building it on dotnet wasnt a great choice3 Replies
What are the warnings?
Putting
<PropertyGroup><TrimMode>partial</TrimMode></PropertyGroup>
in the csproj will likely clear the problem up, but you'll be left with a bigger app that you can't be sure really works (you need to retest all codepaths after publishing and keep doing that every time you make a change). as the warnings say, you chose nuget packages that are not compatible with trimming. there are other command line parsers that work fine with trimming. System.CommandLine should. I think Mono.Options does too. I don't know about YAML parsers. But if you want AOT, you need to pay attention to the warnings and choose your dependencies so that they don't generate the warningsWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.