FROM ubuntu:jammy-20260217
# Install .NET 8 SDK and dependencies
ENV DOTNET_ROOT=/usr/share/dotnet
ENV PATH="$DOTNET_ROOT:$PATH"
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
wget \
ca-certificates \
curl \
gnupg; \
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb; \
dpkg -i packages-microsoft-prod.deb; \
rm packages-microsoft-prod.deb; \
apt-get update; \
apt-get install -y dotnet-sdk-8.0; \
rm -rf /var/lib/apt/lists/*
WORKDIR /src
COPY . .
# Restore, build and test the project from source
RUN dotnet restore Build.csproj
RUN dotnet build Build.csproj --no-restore
RUN dotnet test Build.csproj --no-build --verbosity normal
# Provide an interactive shell by default
CMD ["bash"]
bin/ obj/ .vs/ .vscode/ .idea/ *.user* *.rsmasr *.sln.docstates **/node_modules/ **/bower_components/ .DS_Store ._* .git
Failing step
- [5/7] RUN dotnet restore Build.csproj
Exact error message and exit code
- The command could not be loaded, possibly because:
- You intended to execute a .NET application:
The application 'restore' does not exist.
- You intended to execute a .NET SDK command:
A compatible .NET SDK was not found.
Requested SDK version: 8.0.100
global.json file: /src/global.json
Installed SDKs:
Install the [8.0.100] .NET SDK or update [/src/global.json] to match an installed SDK.
Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
8.0.419 [/usr/share/dotnet/sdk]
ERROR: failed to build: failed to solve: process "/bin/sh -c dotnet restore Build.csproj" did not complete successfully: exit code: 145
What failed
- Command/step: RUN dotnet restore Build.csproj (step 5/7)
Missing packages/files / version mismatch info
- global.json requires SDK version 8.0.100 (path: /src/global.json)
- Installed SDKs available: 8.0.419 (/usr/share/dotnet/sdk)
- This is a version mismatch: 8.0.100 requested vs 8.0.419 installed
Suggested fix (brief)
- Align SDK version by either installing 8.0.100 or updating global.json to match the installed 8.0.419.Error: file not found: src/global.json
FROM ubuntu:jammy-20260217
# Install .NET 8 SDK and dependencies
ENV DOTNET_ROOT=/usr/share/dotnet
ENV PATH="$DOTNET_ROOT:$PATH"
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
wget \
ca-certificates \
curl \
gnupg; \
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb; \
dpkg -i packages-microsoft-prod.deb; \
rm packages-microsoft-prod.deb; \
apt-get update; \
apt-get install -y dotnet-sdk-8.0; \
rm -rf /var/lib/apt/lists/*
WORKDIR /src
COPY . .
# Align SDK version with installed SDK by adjusting global.json if present
RUN if [ -f global.json ]; then echo '{"sdk":{"version":"8.0.419"}}' > global.json; fi
# Restore, build and test the project from source
RUN dotnet restore Build.csproj
RUN dotnet build Build.csproj --no-restore
RUN dotnet test Build.csproj --no-build --verbosity normal
# Provide an interactive shell by default
CMD ["bash"]
Build status: build_failed
Key concerns
- Base image tag is dated: FROM ubuntu:jammy-20260217 (tag may be unavailable or vary across registries).
- COPY . . copies the entire build context (potentially large, unwanted files; cache and security implications).
- global.json override is unconditional when global.json exists; may force SDK version misalignment.
Notable steps and outputs
- Step #4: FROM docker.io/library/ubuntu:jammy-20260217@sha256:ce4a593b4e323dcc3dd728e397e0a866a1bf516a1b7c31d6aa06991baec4f2e0
- Step #6: RUN apt-get update; apt-get install -y --no-install-recommends wget ca-certificates curl gnupg; wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb; dpkg -i packages-microsoft-prod.deb; rm packages-microsoft-prod.deb; apt-get update; apt-get install -y dotnet-sdk-8.0; rm -rf /var/lib/apt/lists/*
- This step was cached.
- Step #8: COPY . . completed (DONE 2.6s)
- Step #9: RUN if [ -f global.json ]; then echo '{"sdk":{"version":"8.0.419"}}' > global.json; fi (DONE 0.5s)
- Step #10: RUN dotnet restore Build.csproj
- Output excerpt:
- Welcome to .NET 8.0!
- SDK Version: 8.0.419
- Installed an ASP.NET Core HTTPS development certificate (trust instructions linked)
- The log here is truncated; no final success/failure message shown in excerpt.
Files and packages referenced
- Base image and tag: ubuntu:jammy-20260217 (digest included)
- Microsoft package: packages-microsoft-prod.deb
- SDK/index: dotnet-sdk-8.0 (installed)
- Local file: global.json (conditionally created)
- Project: Build.csproj
Recommended next steps (brief)
- Consider using a current base image tag or digest to ensure stability.
- Narrow COPY scope or add a .dockerignore to avoid shipping unrelated files.
- If you rely on global.json, ensure it aligns with the SDK you intend to use (or guard/unset as needed).
- Review the full dotnet restore log for the exact error if the build remains failed.Concerns: FROM image tag jammy-20260217 may be outdated or not available in all registries., The build steps rely on a single Build.csproj file; if the repository uses a differently named or multi-project setup, restore/build/test commands may fail., Rewriting global.json to a fixed 8.0.419 when a global.json exists could override the intended SDK version for some projects.