Skip to content

fix: use pre-installed Amazon.Lambda.Tools for dotnet6 builds - #899

Merged
Vandita2020 merged 2 commits into
aws:developfrom
ckawl:fix/dotnet6-use-preinstalled-lambda-tools
Jul 29, 2026
Merged

fix: use pre-installed Amazon.Lambda.Tools for dotnet6 builds#899
Vandita2020 merged 2 commits into
aws:developfrom
ckawl:fix/dotnet6-use-preinstalled-lambda-tools

Conversation

@ckawl

@ckawl ckawl commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

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:

  • Probe for a working tool first (dotnet lambda help). If one is available (e.g. pre-installed in the SAM build
    image), skip the install/update and use it as is.
  • If no tool is available (e.g. local builds outside the build image), fall back to the existing install behavior
    unchanged.
  • The skip deliberately does not set the process-wide __tools_installed flag, so other runtimes in the same process
    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

  • Unit tests added: dotnet6 skips when a tool is pre-installed; dotnet6 falls back to install when absent; other
    runtimes never probe; a dotnet8 build after a dotnet6 skip still installs/updates as before. Full unit suite passes
    (810 tests).
  • End-to-end validated on x86_64: applied this patch to the lambda-builders venv inside the published
    public.ecr.aws/sam/build-dotnet6:latest-x86_64 image, then ran sam build --use-container on a sam init dotnet6
    hello-world app:
    • Unpatched published image: fails with NU1202 (tool update pulls 7.0.0)
    • Patched image: probe detects the pre-installed Amazon.Lambda.Tools 6.0.6, logs "Skipping Amazon.Lambda.Tools
      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.

ckawl added 2 commits July 27, 2026 19:29
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.
@github-actions github-actions Bot added area/workflow/dotnet_clipackage pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Jul 28, 2026
@ckawl
ckawl marked this pull request as ready for review July 28, 2026 03:08
@ckawl
ckawl requested a review from a team as a code owner July 28, 2026 03:08
@Vandita2020
Vandita2020 added this pull request to the merge queue Jul 29, 2026
Merged via the queue into aws:develop with commit 932cb47 Jul 29, 2026
104 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/workflow/dotnet_clipackage pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants