Prerequisites
Steps to reproduce
When I redirect the output and error streams of a native command to two separate files (when I know the command writes to the error stream), both files are created but they are both empty. The error file should contain content. If I redirect only the error stream, the file will contain the correct content.
Here I'm using dotnet as an example but the same thing happens with other commands. If you run dotnet garbage it will write to the error stream.
dotnet >x.txt 2>y.txt garbage
Expected behavior
PS> dotnet >x.txt 2>y.txt garbage
PS> Get-Content y.txt
The command could not be loaded, possibly because:
* You intended to execute a .NET application:
The application 'garbage' does not exist.
* You intended to execute a .NET SDK command:
No .NET SDKs were found.
Download a .NET SDK:
https://aka.ms/dotnet-download
Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
Actual behavior
PS> dotnet >x.txt 2>y.txt garbage
PS> Get-Content y.txt
PS> dotnet 2>y.txt garbage
PS> Get-Content y.txt
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet-garbage does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Error details
Environment data
Name Value
---- -----
PSVersion 7.4.0
PSEdition Core
GitCommitId 7.4.0
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals


Prerequisites
Steps to reproduce
When I redirect the output and error streams of a native command to two separate files (when I know the command writes to the error stream), both files are created but they are both empty. The error file should contain content. If I redirect only the error stream, the file will contain the correct content.
Here I'm using
dotnetas an example but the same thing happens with other commands. If you rundotnet garbageit will write to the error stream.Expected behavior
Actual behavior
Error details
N/AEnvironment data
Visuals