fix: use pre-installed Amazon.Lambda.Tools for dotnet6 builds - #899
Merged
Vandita2020 merged 2 commits intoJul 29, 2026
Merged
Conversation
Amazon.Lambda.Tools 7.0.0 dropped support for net6.0, so installing or updating to latest at build time breaks dotnet6 container builds. For dotnet6, probe for a working tool first (dotnet lambda help) and skip the install/update when one is available - e.g. the version pre-installed in the SAM build image. Local builds without a pre-installed tool keep the existing install behavior.
roger-zhangg
approved these changes
Jul 28, 2026
ckawl
marked this pull request as ready for review
July 28, 2026 03:08
Vandita2020
approved these changes
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
Description of changes
Amazon.Lambda.Tools 7.0.0 dropped support for .NET 6 (net6.0), only supporting net8.0 and net10.0. The
GlobalToolInstall action always installs/updates the tool to latest at build time, so dotnet6 container builds (sam
build --use-container) fail with NU1202 — even though the SAM build image already ships a working, net6-compatible
version of the tool (currently 6.0.6 at /var/lang/bin).
This change makes GlobalToolInstallAction runtime-aware, for dotnet6 only:
image), skip the install/update and use it as is.
unchanged.
still install/update to latest exactly as before.
All other runtimes are unaffected — the probe only runs for dotnet6.
Version-pinning approaches were considered and rejected: NuGet refuses in-place downgrades (tool update --version X
fails when a higher version is installed, and --allow-downgrade only suppresses the warning), and a hardcoded version
in lambda-builders would duplicate ownership of the tool version that belongs to the build image.
Description of how you validated changes
runtimes never probe; a dotnet8 build after a dotnet6 skip still installs/updates as before. Full unit suite passes
(810 tests).
public.ecr.aws/sam/build-dotnet6:latest-x86_64 image, then ran sam build --use-container on a sam init dotnet6
hello-world app:
install/update for dotnet6; using the pre-installed version", and the build succeeds.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.