aws / aws-extensions-for-dotnet-cli

Extensions to the dotnet CLI to simplify the process of building and publishing .NET Core applications to AWS services
Apache License 2.0
369 stars 86 forks source link

dotnet lambda package command relies on zip but doesn't install it #247

Closed FizzBuzz791 closed 1 year ago

FizzBuzz791 commented 1 year ago

Describe the bug

I'm trying to package a lambda using the dotnet lambda package command so that it can be saved as an artifact and used in future steps of the CI/CD pipeline, but the command says:

Failed to find the "zip" utility program in path. This program is required to maintain Linux file permissions in the zip archive.

Expected Behavior

dotnet lambda package runs to completion.

Current Behavior

Tool gets to the zip step and fails. image

Reproduction Steps

  1. Start a new docker container based on the official image: mcr.microsoft.com/dotnet/sdk:6.0
  2. Clone a repo
  3. Build the solution
  4. Install the Amazon.Lambda.Tools tool: dotnet tool install -g Amazon.Lambda.Tools
  5. Add the tool to the path: export PATH="$PATH:/root/.dotnet/tools"
  6. Run the package command: dotnet lambda package --project-location "./src/" --configuration Release --output-package artifacts/package.zip --framework net6.0

Possible Solution

No response

Additional Information/Context

This is an upgrade from .Net2.1 to .Net 6.0, I followed all the steps listed at this page: https://aws.amazon.com/blogs/compute/introducing-the-net-6-runtime-for-aws-lambda/

The repro steps run fine on my local WSL2 instance (Ubuntu LTS) where zip is available. Confirmed via whereis zip.

Targeted .NET platform

6.0.402

CLI extension version

Package Id Version Commands

amazon.lambda.tools 5.5.0 dotnet-lambda

Environment details (OS name and version, etc.)

mcr.microsoft.com/dotnet/sdk:6.0

ashishdhingra commented 1 year ago

Hi @FizzBuzz791,

Good morning.

As the error indicates, you need to have zip package installed. On Debian based Linux distributions, the zip package could be installed using sudo apt install zip (this assumes that you have sudo access).

Are you running this inside the Docker container? If yes, then refer https://stackoverflow.com/questions/41651145/docker-container-not-able-to-locate-zip-packages for possible solution.

Also, you mentioned that you want to use ZIP archive in future steps of the CI/CD pipeline. I think dotnet lambda package-ci would be more suitable for the scenario.

Kindly note that ZIP package is OS level package and is installed differently in various Linux distributions. Hence, .NET CLI Extensions tooling delegates that responsibility to the user.

Thanks, Ashish

FizzBuzz791 commented 1 year ago

Hrmm OK, dotnet lambda package-ci is probably correct, but it's a bigger change than I'm willing to invest in right now. At present, we bundle it up and then use npx sls deploy to get the job done.

The mentioned steps for running inside Docker seem to work, however I'm still trying to understand why there's no dependency management here or at least why there's no warning on install? It warns me about the path not being set correctly, but not that zip isn't installed?

ashishdhingra commented 1 year ago

Hrmm OK, dotnet lambda package-ci is probably correct, but it's a bigger change than I'm willing to invest in right now. At present, we bundle it up and then use npx sls deploy to get the job done.

The mentioned steps for running inside Docker seem to work, however I'm still trying to understand why there's no dependency management here or at least why there's no warning on install? It warns me about the path not being set correctly, but not that zip isn't installed?

@FizzBuzz791 This is probably a feature request to warn about missing tool dependencies and needs review with the team. I'm unsure if it would be prioritized, but would post any update here.

ashishdhingra commented 1 year ago

Closing this in fvor of https://github.com/aws/aws-extensions-for-dotnet-cli/issues/253

github-actions[bot] commented 1 year ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.