Hello.
I try to build arm64 netcore app from docker hub automated build.
I created the next ‘pre_build’ hook:
#!/bin/bash
docker buildx create --name multiarch --use
docker buildx build --no-cache --platform linux/arm64 -f ./Dockerfile.arm64 -t $IMAGE_NAME .
Below, the ‘Dockerfile.arm64’ content:
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
ARG TARGETARCH
ARG BUILDPLATFORM
ADD . /app
WORKDIR /app
RUN dotnet restore "./ProxyVAD.csproj"
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
RUN dotnet publish "./ProxyVAD.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:6.0-alpine
WORKDIR /app
COPY --from=build /app/publish /app
ENTRYPOINT ["dotnet", "ProxyVAD.dll"]
The build succeeds, but architecture image is amd64.
The same docker file used on linux VM on our lab create an arm64 arch image.
If I replace in the Dockerfile the line with dotnet restore with:
RUN dotnet restore "./ProxyVAD.csproj" -a $TARGETARCH
The build fails with the next error:
2025-04-15T15:26:46Z > [linux/amd64->arm64 build 4/5] RUN dotnet restore "./ProxyVAD.csproj" -a arm64:
2025-04-15T15:26:46Z #0 0.819 MSBUILD : error MSB1001: Unknown switch.
2025-04-15T15:26:46Z #0 0.819 Full command line: '/usr/share/dotnet/sdk/6.0.428/MSBuild.dll -maxcpucount -verbosity:m -nologo -target:Restore ./ProxyVAD.csproj -a arm64 -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,/usr/share/dotnet/sdk/6.0.428/dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,/usr/share/dotnet/sdk/6.0.428/dotnet.dll'
2025-04-15T15:26:46Z #0 0.819 Switches appended by response files:
2025-04-15T15:26:46Z #0 0.819 Switch: -a
2025-04-15T15:26:46Z #0 0.819
What Am I missing ?
Kind regards.