Skip to content

Publish with "Trim unused code" #141

Answered by Tyrrrz
KoalaBear84 asked this question in Q&A
Discussion options

You must be logged in to vote

CliFx is not trim-compatible in its current state and it would take a lot of effort to make it compatible (essentially rewriting it with source-generators), due to the heavy use of type-walking and dynamic type conversions.

In order to get your CLI app working with CliFx with assembly trimming, you have to manually preserve your commands, converters, and other dynamically referenced members (such as Parse(...) methods on applicable types, when used for conversion).

See here for a working example: https://github.com/Tyrrrz/DiscordChatExporter/blob/c8ea365c04498bea973c38e2ed028e8c31a05bb0/DiscordChatExporter.Cli/Program.cs#L13-L40. Feel free to narrow the DynamicallyAccessedMemberTypes to t…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@KoalaBear84
Comment options

@KoalaBear84
Comment options

Answer selected by KoalaBear84
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants