dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.73k stars 1.07k forks source link

dotnet tool fails to run tools in localized languages #24059

Open yaakov-h opened 2 years ago

yaakov-h commented 2 years ago

Describe the bug

When running the .NET SDK in (at least some) languages that have localized language packs, dotnet tool run fails to correctly delineate between its own arguments and arguments intended for the tool that the user wishes to run.

This does not occur in English (United States) or עברית, but does occur in Deutsch (Deutschland) and Español (España), under Windows 10 and Windows 11.

To Reproduce

To setup:

dotnet new tool-manifest
dotnet tool install excubo.webcompiler

To repro:

dotnet tool run webcompiler -r a

Expected Output:

a does not exist

Actual Output:

German:

Befehl oder Argument "-r" nicht erkannt
Befehl oder Argument "a" nicht erkannt
Description:
  Hiermit wird das lokale Tool ausgeführt.

Usage:
  dotnet [options] tool run <COMMAND_NAME> [[--] <additional arguments>...]]

Arguments:
  <COMMAND_NAME>  Der Befehlsname des auszuführenden Tools.

Options:
  -?, -h, --help  Hiermit wird die Hilfe zur Befehlszeile angezeigt.

Additional Arguments:
  Arguments passed to the application that is being run.

Spanish:

No se reconoce el comando o el argumento "-r"
No se reconoce el comando o el argumento "a"
Description:
  Ejecutar la herramienta local.

Usage:
  dotnet [options] tool run <COMMAND_NAME> [[--] <additional arguments>...]]

Arguments:
  <COMMAND_NAME>  El nombre de comando de la herramienta que se va a ejecutar.

Options:
  -?, -h, --help  Muestra ayuda de la línea de comandos.

Additional Arguments:
  Arguments passed to the application that is being run.

Additional Notes:

I have managed to reproduce this with both excubo.webcompiler (as shown above) and protobuf-net.protogen.

As a workaround, -- can be inserted between the tool name and the arguments intended for the tool, e.g. dotnet tool run webcompiler -- -r a

This issue occurs on .NET SDK 6.0.100 and 7.0.100-preview.1.22110.4 at least. I expect the entire 6.x line is affected.

Further technical details

Reproduced on the Windows 11 Pro Azure VM template, running v21H2 build 22000.493.

.NET SDK (reflecting any global.json):
 Version:   6.0.100
 Commit:    9e8b04bbff

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.100\

Host (useful for support):
  Version: 7.0.0-preview.1.22076.8
  Commit:  405337939c

.NET SDKs installed:
  6.0.100 [C:\Program Files\dotnet\sdk]
  6.0.101 [C:\Program Files\dotnet\sdk]
  6.0.102 [C:\Program Files\dotnet\sdk]
  7.0.100-preview.1.22110.4 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0-preview.1.22109.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0-preview.1.22076.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.0-preview.1.22077.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
baronfel commented 2 years ago

This should get solved as part of https://github.com/dotnet/sdk/issues/24068, moving towards an explicit argument array should give the parser enough information to do the expected correct thing.

yaakov-h commented 2 years ago

Does that mean that this will only get solved for .NET 7, and the LTS release will remain broken?