cake icon indicating copy to clipboard operation
cake copied to clipboard

`DotNetSlnList` hardcodes English output

Open fdw opened this issue 1 month ago • 4 comments

Prerequisites

  • [x] I have written a descriptive issue title
  • [x] I have searched issues to ensure it has not already been reported

Cake runner

Cake Frosting

Cake version

5.1.0

Operating system

Windows

Operating system architecture

x64

CI Server

No response

What are you seeing?

When running context.DotNetSlnList(SolutionFile), no projects are returned. This seems to be because the output is parsed in DotNetSlnLister.ParseResult, but it expects Project(s). If the machine is configured with a different locale, it obviously doesn't match and nothing is returned.

What is expected?

All projects are listed independent of the system's locale

Steps to Reproduce

  1. Configure a different locale than English.
  2. Call context.DotNetSlnList()
  3. Observe that this solution contains no projects.

Output log

No response

fdw avatar Dec 01 '25 11:12 fdw

Does it work for you if you specify cli language, i.e.

var projects = DotNetSlnList(
                    ".",
                    new DotNetSlnListSettings
                    {
                        EnvironmentVariables =
                        {
                            { "DOTNET_CLI_UI_LANGUAGE",  "en" }
                        }
                    }
                );

if so that would be a current workaround, and maybe should be added by default in alias for future versions.

devlead avatar Dec 01 '25 16:12 devlead

Yes, that does work. But personally, I'd prefer to make the ParseResult more robust and maybe simpy ignore the first line completely. Maybe the user has already set that env var for some other purpose?

fdw avatar Dec 02 '25 06:12 fdw

EnvironmentVariables on ToolSettings are only for that child process and doesn't affect anything else for current script/user/system.

devlead avatar Dec 02 '25 06:12 devlead

True, and it's your decision 🙂

I'm just wary of hardcoding the expected output.

fdw avatar Dec 02 '25 07:12 fdw

Not much we can do unless structured output is provided by the tool.

patriksvensson avatar Dec 12 '25 12:12 patriksvensson

As I said, you could ingore the first line in any case, no matter what it says :)

fdw avatar Dec 12 '25 12:12 fdw

I think the only consistent way to ensure consistent known output is to set DOTNET_CLI_UI_LANGUAGE environment variable. If it outputs an error or something unknown then it's risky to assume those are file paths to projects,

6.1 will have a basic slnx parser added with #4666, so ParseSolution alias is probably a better option.

devlead avatar Dec 12 '25 15:12 devlead