runtime: Cannot build docker app after upgrade to .NET 8 (with blazor)

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I cannot build a project after upgrading to .NET 8, and it seems it is related to “wasm-tools”?

 > [build 19/20] RUN dotnet build "--project--.csproj" -c Release -o /app/build:
29.72 /src/--path--/Pages/Confirm/ConfirmPage.razor(81,29): warning CS8602: Dereference of a possibly null reference. [/src/--path--.csproj]
29.72 emcc : error : '/usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Node.linux-x64/8.0.0/tools/bin/node /usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Sdk.linux-x64/8.0.0/tools/emscripten/src/compiler.js /tmp/tmpv5fivgad.json --symbols-only' failed (returned 127) [/src/--path--.csproj]
29.72 /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/8.0.0/Sdk/WasmApp.Native.targets(513,5): error MSB3073: The command "emcc "@/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/8.0.0/runtimes/browser-wasm/native/src/emcc-default.rsp" -msimd128 "@/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/8.0.0/runtimes/browser-wasm/native/src/emcc-link.rsp" "@/src/--path--/obj/Release/net8.0/wasm/for-build/emcc-link.rsp"" exited with code 1. [/src/--path--/--path--.csproj]
29.72 emcc : error : '/usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Node.linux-x64/8.0.0/tools/bin/node /usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Sdk.linux-x64/8.0.0/tools/emscripten/src/compiler.js /tmp/tmphjdr3gmv.json --symbols-only' failed (returned 127) [/src/--path--.csproj]
29.72 /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/8.0.0/Sdk/WasmApp.Native.targets(513,5): error MSB3073: The command "emcc "@/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/8.0.0/runtimes/browser-wasm/native/src/emcc-default.rsp" -msimd128 "@/usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/8.0.0/runtimes/browser-wasm/native/src/emcc-link.rsp" "@/src/--path--/obj/Release/net8.0/wasm/for-build/emcc-link.rsp"" exited with code 1. [/src/--path--.csproj]

Docker file:

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

#EXPOSE 80
#EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

# Setup xarn
RUN apt-get update
RUN apt-get install -y python3
RUN apt-get install ca-certificates curl gnupg -yq
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
RUN apt-get update
RUN apt-get install -y nodejs
RUN apt-get install -y apt-transport-https
#RUN apt-get --assume-yes install yarn

RUN dotnet workload install wasm-tools
RUN dotnet workload install wasm-experimental

# Build
COPY ["src", "src/"]
COPY [".git", ".git/"]

WORKDIR "/"

## RUN dotnet nuget add source ... (omit)


RUN dotnet restore "src/--path--/project.csproj"
COPY . .

WORKDIR "/src/--path--"
RUN dotnet build "project.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "project.csproj" -c Release -o /app/publish

# Build final image

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "project.dll"]

Expected Behavior

No response

Steps To Reproduce

Upgrade existing app to .NET with enabled features which require (or required?) wasm-tools.

If i comment on the two lines with wasm-tools it builds. Also “release” mode seems to work in local windows env.

Exceptions (if any)

No response

.NET Version

No response

Anything else?

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 19 (11 by maintainers)

Most upvoted comments

@jirisykora83 I have similar issue but in the logs I see also some more detailed error: /usr/share/dotnet/packs/Microsoft.NET.Runtime.Emscripten.3.1.34.Node.linux-x64/8.0.0/tools/bin/node: error while loading shared libraries: libatomic.so.1: cannot open shared object file: No such file or directory After adding install of this library to Dockerfile RUN apt-get install -y libatomic1 project is building without error

@lbussell is Python in mcr.microsoft.com/dotnet/sdk:8.0?

No. We don’t have a sample showing how to build a Blazor WASM app with .NET Docker images (which would involve installing Python). It is tracked by https://github.com/dotnet/dotnet-docker/issues/5070.

is this still needed and if so what are the next steps

@lewing I think the core issue described by the OP is fixed, since .NET SDK Dockerfiles now include libatomic. That was tracked by https://github.com/dotnet/dotnet-docker/issues/5033.

We should do what @baronfel suggested, and get libatomic1 added to the Docker images which might try to run node.

This is a small price we paid to increase our support matrix to cover older distributions than we did under .NET 7.

Node will add libatomic to its list of linked libraries when built with Clang - https://github.com/nodejs/node/blob/v18.x/node.gyp#L124-L126

Upstream Node 18.x is built against GCC/libstdc++ 8.5.0; we use Clang/libc++ 16.x. That’s why the upstream packages don’t include a libatomic1 dependency. Building & linking our self-built Clang/libc++ was required, because the .NET 8 target Linux distribution only has GCC/libstdc++ 5.3.1, which doesn’t include support for C++17 (a prerequisite for emsdk).