Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli errors do not go to stderror stream #2476

Closed
esmadau opened this issue Aug 3, 2022 · 3 comments
Closed

cli errors do not go to stderror stream #2476

esmadau opened this issue Aug 3, 2022 · 3 comments
Labels
external An issue in an external dependency

Comments

@esmadau
Copy link

esmadau commented Aug 3, 2022

swashbuckle version: 6.1.4 and 6.4.0

In a case where .NET version expected to be able to use dotnet swagger is not found, the output seems like it should be an error, but instead is just informational. This is causing issues when trying to use this in processes where an error is expected to fail the task appropriately, whether the failure occurs on writing the file or anything else around using dotnet swagger.
This seems to be a general issue, not relating to a specific version of the cli.

Repro:

  • ensure 'Microsoft.AspNetCore.App', version '5.0.0' is not installed
  • use swashbuckle version 6.1.4
  • ensure $ErrorActionPreference is set to default of Continue when running in Powershell
  • use dotnet swagger in try catch, see that error does not occur. Ex: try{dotnet swagger}catch{Write-Host "error occurred."}

Example:

PS C:\dev\> try{dotnet swagger}catch{Write-Host "error occurred."}
You must install or update .NET to run this application.

App: C:\Users\x\.nuget\packages\swashbuckle.aspnetcore.cli\6.1.4\tools\net5.0\any\dotnet-swagger.dll
Architecture: x64
Framework: 'Microsoft.AspNetCore.App', version '5.0.0' (x64)
.NET location: C:\Program Files\dotnet\

The following frameworks were found:
  6.0.7 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]

Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed

To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=5.0.0&arch=x64&rid=win10-x64
PS C:\dev\>

Repro:

  • use swashbuckle version 6.4.0
  • ensure $ErrorActionPreference is set to default of Continue when running in Powershell
  • use dotnet swagger in try catch with a wrong path to assembly, see that error does not occur. Ex: try{dotnet swagger tofile --output unknown src\unknown.dll v1}catch{Write-Host "error occured."

An error is also not thrown when the assembly provided is not found:

PS C:\dev\> try{dotnet swagger tofile --output unknown src\unknown.dll v1}catch{Write-Host "error occured."}
Unhandled exception. System.IO.FileNotFoundException: src\unknown.dll
   at Swashbuckle.AspNetCore.Cli.Program.<>c__DisplayClass0_0.<Main>b__2(IDictionary`2 namedArgs) in C:\projects\ahoy\src\Swashbuckle.AspNetCore.Cli\Program.cs:line 41
   at Swashbuckle.AspNetCore.Cli.CommandRunner.Run(IEnumerable`1 args) in C:\projects\ahoy\src\Swashbuckle.AspNetCore.Cli\CommandRunner.cs:line 68
   at Swashbuckle.AspNetCore.Cli.CommandRunner.Run(IEnumerable`1 args) in C:\projects\ahoy\src\Swashbuckle.AspNetCore.Cli\CommandRunner.cs:line 59
   at Swashbuckle.AspNetCore.Cli.Program.Main(String[] args) in C:\projects\ahoy\src\Swashbuckle.AspNetCore.Cli\Program.cs:line 121
@esmadau
Copy link
Author

esmadau commented Aug 3, 2022

Is this related to dotnet cli in general streaming everything to stdout? dotnet/sdk#7289 (comment)

Copy link
Contributor

This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.

@github-actions github-actions bot added the stale Stale issues or pull requests label Apr 19, 2024
@martincostello martincostello removed the stale Stale issues or pull requests label Apr 19, 2024
@martincostello
Copy link
Collaborator

Yep, this is an issue with .NET rather than us. Our code doesn't get executed in this scenario.

@martincostello martincostello closed this as not planned Won't fix, can't repro, duplicate, stale Apr 19, 2024
@martincostello martincostello added the external An issue in an external dependency label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external An issue in an external dependency
Projects
None yet
Development

No branches or pull requests

2 participants