0

I run dotnet from powershell script, and when I specify some unknown switch powershell does not detect any error. And output goes to stdout whereas I'd expect it to be stderr.

Is it a setting on dotnet or powershell side? I need script to fail in case of errors.

dotnet pack -dsfsdf Microsoft (R) Build Engine version 15.8.166+gd4e8d81a88 for .NET Core Copyright (C) Microsoft Corporation. All rights reserved.

MSBUILD : error MSB1001: Unknown switch. Switch: -dsfsdf

For switch syntax, type "MSBuild /help"

silkfire
  • 24,585
  • 15
  • 82
  • 105
Pavel Voronin
  • 13,503
  • 7
  • 71
  • 137

1 Answers1

3

Indeed dotnet-pack writes errors to stdout, however it sets exit code to 1 in case of unknown parameter. You can check it with following code:

dotnet pack -asd
echo $LASTEXITCODE