Closed Beau-Gosse-dev closed 1 year ago
To work around this issue for now in the SAM CLI, update SAM CLI to the latest version, and then pass the -u
flag to sam build
in order to tell SAM CLI to spin up the container instead. Make sure to have the latest version of SAM CLI (1.78.0), otherwise the -u
flag may not work for .NET. Since this bug is related to the container path being different than the host path, if SAM CLI spins up the container, Amazon.Lambda.Tools won't need to consider a container path.
So the command would look like this:
sam build -u
Argument description:
-u, --use-container Build functions within an AWS Lambda-like
container.
PR has been released with the fix.
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.
Describe the bug
When running a
dotnet publish
on a container without setting"msbuild-parameters": "--self-contained true"
inaws-lambda-tools-defaults.json
, the code tries to look up the project file to look for properties inside it, however at that point, the project file path is for use inside the container at/tmp/source
so the host process can't find the project file and errors out.Expected Behavior
The code should use the project file path on the host to find the file
Current Behavior
It uses the container path and errors out since the container isn't started yet.
Reproduction Steps
try to
dotnet lambda package
a native AOT .NET 7 app without"msbuild-parameters": "--self-contained true"
inaws-lambda-tools-defaults.json
Possible Solution
https://github.com/aws/aws-extensions-for-dotnet-cli/pull/275
Additional Information/Context
Found in this canary which uses SAM CLI: https://github.com/aws-samples/serverless-dotnet-demo/actions/runs/4673160677/jobs/8276085135
Targeted .NET platform
net7
CLI extension version
5.6.5
Environment details (OS name and version, etc.)
windows 10