Skip to content

fix(Lambda.Tools): map Lambda architecture to .NET store directory for publish-layer - #458

Draft
GarrettBeatty wants to merge 1 commit into
masterfrom
gcbeatty/issue-457-fix
Draft

GarrettBeatty wants to merge 1 commit into
masterfrom
gcbeatty/issue-457-fix

Conversation

@GarrettBeatty

Copy link
Copy Markdown
Contributor

Issue

Fixes #457

dotnet lambda publish-layer fails with Failed to find artifact.xml file in created local store. when --function-architecture x86_64 is specified.

Root cause

In PublishLayerCommand.CreateRuntimePackageStoreLayerZipFile, the AWS Lambda architecture value (e.g. x86_64) was used verbatim as the .NET store subdirectory name when building the artifact.xml lookup path. dotnet store (via LambdaDotNetCLIWrapper.Store, which passes --runtime linux-x64) writes output under the .NET RID architecture folder name x64, not the Lambda name x86_64. So the lookup built .../store/x86_64/<tfm>/artifact.xml while the file actually existed at .../store/x64/<tfm>/artifact.xml, failing the File.Exists check.

  • arm64 worked because the Lambda name equals the .NET folder name.
  • The unspecified case worked via the old ?? "x64" default.

Fix

  • Add LambdaUtilities.DetermineStoreArchitectureDirectory to translate the AWS Lambda architecture value to the .NET store directory name, mirroring the existing DetermineRuntimeParameter logic (arm64 -> arm64; everything else, including x86_64, null, empty -> x64, preserving the previous default).
  • Use the helper in PublishLayerCommand when composing the artifact.xml path.

Testing

  • Added regression [Theory] TestDetermineStoreArchitectureDirectory in test/Amazon.Lambda.Tools.Test/UtilitiesTests.cs covering x86_64->x64, arm64->arm64, ARM64 (case-insensitive)->arm64, null->x64, ""->x64, and an unexpected value (foo)->x64.
  • dotnet test --filter TestDetermineStoreArchitectureDirectory: 6 passed, 0 failed.
  • Amazon.Lambda.Tools.csproj builds clean (0 warnings / 0 errors).

publish-layer built the artifact.xml lookup path using the AWS Lambda
architecture value (e.g. x86_64) verbatim as the .NET store subdirectory
name. 'dotnet store' writes under the .NET RID arch folder (x64), not the
Lambda name (x86_64), so --function-architecture x86_64 failed with
'Failed to find artifact.xml file in created local store.'

Add LambdaUtilities.DetermineStoreArchitectureDirectory to translate the
Lambda arch name to the .NET store dir name, mirroring DetermineRuntimeParameter,
and use it in PublishLayerCommand. Preserves the previous '?? x64' default for
null/empty/unspecified. Adds a regression [Theory] in UtilitiesTests.

Fixes #457
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Publish-layer fails to find artifact.xml on x86_64 with .NET 10

1 participant