Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse command line arguments/options in C#

I have a console application with some arguments and options so I would like to use a free third-party library.

I have found two libraries for this purpose: NDesk.Options and Command Line Parser Library

Finally I have decided to use Command Line Parser Library because it is clearer using properties so I have downloaded it and added a reference to it.

The problem is that when adding the reference to my .NET Framework 3.5 project I get a warning icon. From the above page where I have downloaded it, it says that compatibility is .NET Framework 3.5+ so I understand 3.5 is compatible, am I right? If not which previous version of it is compatible with .NET Framework 3.5?

like image 295
Ralph Avatar asked Jul 09 '26 02:07

Ralph


1 Answers

System.CommandLine might do the trick. Though as of October 2023 it is still in the preview/beta status. I suppose the .NET team is going to include it in some upcoming .NET framework release.

https://github.com/dotnet/runtime/issues/68578 https://www.nuget.org/packages/System.CommandLine

March 2024 update:

We are resetting the System.CommandLine project to better align with the current ecosystem, isolate parsing behavior so it can be shares with other parser libraries and clarify long term maintenance. This work is intended to bring System.CommandLine out of preview mode.

https://github.com/dotnet/command-line-api/issues/2338

like image 161
Artur Beljajev Avatar answered Jul 11 '26 16:07

Artur Beljajev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!