Open AnthonyMastrean opened 2 hours ago
Would be mitigated by machine-readable output (#13649)
I'm going to close this as not a bug since this has more to do with the encoding used by whatever system writes the output to a file.
Running this command in a Windows command-line window works fine:
dotnet nuget why ClassLibrary1.csproj NuGet. > test.txt
The file emitted looks like:
Project 'ClassLibrary1' has the following dependency graph(s) for 'Newtonsoft.Json':
[net6.0]
│
└─ Newtonsoft.Json.Bson (v1.0.2)
└─ Newtonsoft.Json (v12.0.1)
Running this in PowerShell works with -Encoding Oem
but not -Encoding Unicode
:
dotnet nuget why ClassLibrary1.csproj Newtonsoft.Json | Set-Content .\test.txt -Encoding Oem
Project 'ClassLibrary1' has the following dependency graph(s) for 'Newtonsoft.Json':
[net6.0]
│
└─ Newtonsoft.Json.Bson (v1.0.2)
└─ Newtonsoft.Json (v12.0.1)
NuGet itself is writing the correct characaters to STDOUT and cannot control what mechanism is used to then write the stream to a file.
If you want to use the output in a program, then we recommend you instead use the JSON output.
NuGet Product Used
dotnet.exe
Product Version
.NET SDK 8.0.401
Worked before?
No
Impact
It bothers me. A fix would be nice
Repro Steps & Context
Interactive output has these fancy tree characters.
But those don't survive into a file whether by
Out-File
orSet-Content
with or without any-Encoding utf8
.Verbose Logs
No response