Skip to content

LibMan CLI returns zero exit code even when there was an error #682

@msvprogs

Description

@msvprogs

Describe the bug

Even if LibMan CLI operation has finished with errors, exit code of the process is 0. This is a little inconvenient for build scripts or Dockerfiles when you don't know that some libraries haven't been restored, for example, because of library CDN provider's temporary unavailability or bugs. The only workaround is to check stderr and fail when there is any output, but it seems that returning non-zero exit code would be a more clear indication that something went wrong.

To Reproduce

Steps to reproduce the behavior:

  1. Create temporary Docker container with .NET 5.0 SDK and attach to its terminal:
sudo docker run --rm -it mcr.microsoft.com/dotnet/sdk:5.0
  1. Install LibMan CLI tool
export PATH="$PATH:/root/.dotnet/tools"
dotnet tool install -g Microsoft.Web.LibraryManager.Cli
  1. Perform any illegal operation. For example, try to restore libraries in the directory without libman.json file.
root@0f7d49cfdfcc:/# libman restore
libman.json was not found:/libman.json
  1. Check exit code of libman:
root@0f7d49cfdfcc:/# echo $?
0
  1. Exit code is zero despite libman command failure

Expected behavior

Exit code of libman is non-zero

Additional context

LibMan CLI version: 2.1.161+abc97ecc7d.RR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions