Is there any difference between the dotnet command parameters

Is there any difference between the dotnet command parameters

-o , --output
and
-n, --name

Should one prefer one over the other for any reason
those two commands seem to do the exact same thing

dotnet new console --output helloworld2 -lang F#

dotnet new console --name helloworld -lang F#

Welcome to the forums Gail207Matrinez.

As far as I know hereā€™s not much difference, in general, between the single-dash and double-dash ways of doing it when both ways are available.

There are some options which donā€™t have the single-dash form and there may be some that donā€™t have the double-dash form.

There may be some differences for some specific options but those differences should be documented for those specific options.

Iā€™ve been using the single-dash versions almost exclusively and havenā€™t had any problems yet (except when Iā€™ve used them wrong).

Note: Some double-dash options, for some commands, became subcommands in .NET 7 SDK, so it all gets a bit complicated once you ā€˜dive inā€™.

As for ā€œā€”nameā€ versus ā€œā€”outputā€ question, I canā€™t answer that as there may be some specific ā€˜under-the-hoodā€™ details that Iā€™m not aware of.

What I can say about it is that I have been using ā€œ-nā€ to automatically create the folder name for me without issue ā€“ Iā€™ve never tried ā€œ-oā€ or ā€œā€”outputā€.

Short hand is for typing, long hand is for scripts.

Is there some technical reason for that?

And is it a ā€˜hard-and-fastā€™ rule, or is there some ā€˜wiggle-roomā€™?

Sorry for the short reply earlier. At least for me I am using the short hand notation when I am typing in the terminal. It is faster and more lean and I have probably looked at the documentation right before invoking the command. If there are long forms of the options and I have a need to use these commands in a script then I will put in the extra effort to use the long form. This helps me later when I am trying to figure out what my script is doing (might not need to read the documentation again). So thatā€™s how I reason about short vs long forms. What do you guys think?

While Iā€™ve not used dotnet commands in a script I can see where having the command in ā€˜long formā€™ would be useful.

I imagine it makes it easier to spot the options when there are lots of them; for example itā€™s probably easier to accidentally miss something short like ā€œ-dā€ than it would be to miss something like ā€œā€“diagnosticsā€.

Itā€™s also a kind of free (basic) documentation I guess.

1 Like