BuildX for arm64 on .Net 7.0 is broken
See original GitHub issueWhen try to build arm64 containers using .Net7 results in a error on restore step.
Just create a new web api for example with .Net7 as target framework and try to build it with buildx. For amd64 build works just fine.
PS C:\Users\Marcio\OneDrive\Documents\VSCode\asp.net\EspUpdater> docker buildx build --platform linux/arm64 -t zimbres/espupdater -f .\src\EspUpdater\Dockerfile --push . --no-cache
[+] Building 66.2s (12/17)
=> [internal] load .dockerignore 0.1s
=> => transferring context: 382B 0.0s
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 622B 0.0s
=> [internal] load metadata for mcr.microsoft.com/dotnet/sdk:7.0 2.3s
=> [internal] load metadata for mcr.microsoft.com/dotnet/aspnet:7.0 2.0s
=> [build 1/7] FROM mcr.microsoft.com/dotnet/sdk:7.0@sha256:39069a126f2e3dd8f3aa72a21688d4de13ba23b051a8c5856be1460f8165c422 52.0s
=> => resolve mcr.microsoft.com/dotnet/sdk:7.0@sha256:39069a126f2e3dd8f3aa72a21688d4de13ba23b051a8c5856be1460f8165c422 0.0s
=> => sha256:d508dcfcdd2e1834750cbcc43a9e0f44625d7cdbb349be5342f069a0a26a9d20 13.42MB / 13.42MB 8.7s
=> => sha256:edd0ccac63956573208572413f089dcc51a922baced37a1c3588d55701aab5c3 150.47MB / 150.47MB 38.8s
=> => sha256:62558e356c6cd900192712f446fefcd8029f9f54b12c87b4b342a392d2e9e9ed 25.39MB / 25.39MB 11.1s
=> => extracting sha256:62558e356c6cd900192712f446fefcd8029f9f54b12c87b4b342a392d2e9e9ed 1.7s
=> => extracting sha256:edd0ccac63956573208572413f089dcc51a922baced37a1c3588d55701aab5c3 3.2s
=> => extracting sha256:d508dcfcdd2e1834750cbcc43a9e0f44625d7cdbb349be5342f069a0a26a9d20 0.3s
=> [internal] load build context 0.1s
=> => transferring context: 6.72kB 0.0s
=> [base 1/2] FROM mcr.microsoft.com/dotnet/aspnet:7.0@sha256:cc60f5590843f067871d72ffc99d3065f8556624d45465948166b11a08714ddc 22.7s
=> => resolve mcr.microsoft.com/dotnet/aspnet:7.0@sha256:cc60f5590843f067871d72ffc99d3065f8556624d45465948166b11a08714ddc 0.0s
=> => sha256:9855365906865f18e48e4132950bb1f031a37afd9487af259eb8618313aaa672 9.80MB / 9.80MB 6.2s
=> => sha256:e48426b90b5fe27894046a6b96e67e208ec25e2768a1c5bf76d233fa1ec1e7d6 155B / 155B 0.3s
=> => sha256:eafd3893bf918fb60399acce35d47fc92934372f519a0dc8ea56b7ae552a1524 30.71MB / 30.71MB 19.1s
=> => sha256:dd6189d6fc13cb03db0f4a3d9659b6b6044fd5858019d659001eaf8367584d67 30.06MB / 30.06MB 19.4s
=> => sha256:8487b5d2f3511cc5ae78d3f730d7f7e8f06466f6281464355fd6a464c95cab36 14.92MB / 14.92MB 9.2s
=> => extracting sha256:dd6189d6fc13cb03db0f4a3d9659b6b6044fd5858019d659001eaf8367584d67 1.5s
=> => extracting sha256:8487b5d2f3511cc5ae78d3f730d7f7e8f06466f6281464355fd6a464c95cab36 0.4s
=> => extracting sha256:eafd3893bf918fb60399acce35d47fc92934372f519a0dc8ea56b7ae552a1524 0.8s
=> => extracting sha256:e48426b90b5fe27894046a6b96e67e208ec25e2768a1c5bf76d233fa1ec1e7d6 0.0s
=> => extracting sha256:9855365906865f18e48e4132950bb1f031a37afd9487af259eb8618313aaa672 0.3s
=> [base 2/2] WORKDIR /app 0.7s
=> [final 1/2] WORKDIR /app 0.1s
=> [build 2/7] WORKDIR /src 1.4s
=> [build 3/7] COPY [src/EspUpdater/EspUpdater.csproj, src/EspUpdater/] 0.0s
=> ERROR [build 4/7] RUN dotnet restore "src/EspUpdater/EspUpdater.csproj" 10.5s
------
> [build 4/7] RUN dotnet restore "src/EspUpdater/EspUpdater.csproj":
#0 10.13 /usr/share/dotnet/sdk/7.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(55,5): error MSB4184: The expression "[MSBuild]::GetTargetFrameworkVersion(net7.0, 2)" cannot be evaluated. Exception has been thrown by the target of an invocation. [/src/src/EspUpdater/EspUpdater.csproj]
------
Dockerfile:8
--------------------
6 | WORKDIR /src
7 | COPY ["src/EspUpdater/EspUpdater.csproj", "src/EspUpdater/"]
8 | >>> RUN dotnet restore "src/EspUpdater/EspUpdater.csproj"
9 | COPY . .
10 | WORKDIR "/src/src/EspUpdater"
--------------------
ERROR: failed to solve: process "/bin/sh -c dotnet restore \"src/EspUpdater/EspUpdater.csproj\"" did not complete successfully: exit code: 1
Docker Version
PS C:\Users\Marcio\OneDrive\Documents\VSCode\asp.net\EspUpdater> docker version
Client:
Cloud integration: v1.0.29
Version: 20.10.20
API version: 1.41
Go version: go1.18.7
Git commit: 9fdeb9c
Built: Tue Oct 18 18:28:44 2022
OS/Arch: windows/amd64
Context: default
Experimental: true
Server: Docker Desktop 4.13.1 (90346)
Engine:
Version: 20.10.20
API version: 1.41 (minimum version 1.12)
Go version: go1.18.7
Git commit: 03df974
Built: Tue Oct 18 18:18:35 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.8
GitCommit: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Docker Info
PS C:\Users\Marcio\OneDrive\Documents\VSCode\asp.net\EspUpdater> docker info
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., v0.9.1)
compose: Docker Compose (Docker Inc., v2.5.1)
dev: Docker Dev Environments (Docker Inc., v0.0.3)
extension: Manages Docker extensions (Docker Inc., v0.2.13)
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
scan: Docker Scan (Docker Inc., v0.21.0)
Server:
Containers: 18
Running: 4
Paused: 0
Stopped: 14
Images: 40
Server Version: 20.10.20
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
Default Runtime: runc
Init Binary: docker-init
containerd version: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
runc version: v1.1.4-0-g5fd4c4d
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 5.10.102.1-microsoft-standard-WSL2
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 12
Total Memory: 15.6GiB
Name: docker-desktop
ID: BGP4:KFNX:A6XV:MDJT:AKET:PD7L:O7YG:6SHF:KNRB:EFFD:PD3W:6OC2
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5000
127.0.0.0/8
Live Restore Enabled: false
WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
Issue Analytics
- State:
- Created 10 months ago
- Reactions:12
- Comments:13 (9 by maintainers)
Top Results From Across the Web
zsh - .Net 7.0 arm64 installer broken?
Today I tried installing .net to learn basics of it. However, after running the installer I was not able to run dotnet commands...
Read more >docker buildx build
The buildx build command starts a build using BuildKit. This command is similar to the UI of docker build command and takes the...
Read more >Cannot debug net6.0-macos Apps - Developer Community
It seems that the latest update to 17.4.1. fixed the issue! I'm now able to run my macOS .Net 7 app in debug...
Read more >What's new in .NET 8
NET 8 is the successor to .NET 7. It will be supported for three years as a long-term support (LTS) release. You can...
Read more >Test runner broken for macOS with M1 (Apple Silicon) for x64 ...
In the test output, there is the following error, which shows that the test runner is looking for an arm64 version of the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This appears to be a bug with NuGet running with QEMU (Quick Emulator). QEMU is being used here by Docker because you’re running Arm64 on an x64 host machine.
In the meantime, let’s talk about a workaround. You’ll want to avoid emulation by not using a multi-arch tag for the sdk. To do this, you can use the
7.0-bullseye-slim-amd64
tag. You should only need to use that for the sdk stage of your Dockerfile. The final stage can still use the multi-arch tag (7.0
).But because you’re explicitly using the amd64 version of the sdk image, you’ll need to explicitly set the RID in the
restore
andpublish
commands. And because the RID is set you’ll also need to disable theself-contained
option if you don’t want a self-contained deployment.And there’s one little gotcha with the architecture. In order to make it a truly multi-arch Dockerfile, you’d also need to account for when you specify
--platform linux/amd64
. In that case, the RID needs to usex64
notamd64
, so there’s some logic in the Dockerfile below which shows how to fix that up as well.Note that in the Dockerfile below I make use of the
TARGETARCH
andTARGETOS
arguments. You don’t need to explicitly pass these arguments with the--build-arg
option. They are automatically derived by using the--platform
option. So you shouldn’t need to change how you run the build command.Example:
I’ve created a new issue for this at: https://github.com/NuGet/Home/issues/12227