dotnet run
writes the "Using launch settings from ..." message to stdout instead of stderr #45640
Open
Description
Describe the bug
[On a Mac M1 using .NET 9.]
When using dotnet run
to run a project that uses a launchSettings.json
file, it writes a startup message like "Using launch settings from {filename}..." to stdout. Other run messages are written (correctly) to stderr. Because the message is written to stdout, it mixes in with the expect output of the program, often making it unparseable.
To Reproduce
- Clone this simple console project example: https://github.com/Aethon/DotNetOutputExample.
- Execute
dotnet run > output.json
. - Examine
output.json
and note that it is not valid JSON due to the message at the top.
Further technical details
The errant line of code is here: https://github.com/dotnet/sdk/blob/main/src/Cli/dotnet/commands/dotnet-run/RunCommand.cs#L135.