Skip to content

Cannot build docker app after upgrade to .NET 8 (with blazor) #95477

Closed

Description

@jirisykora83

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

Activity

  1. kmrzyglod commented on Nov 17, 2023

    @kmrzyglod

    @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

  2. jirisykora83 commented on Nov 17, 2023

    @jirisykora83
    Author

    @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

    Thank you, I tested it and it indeed resolved my issue. I leave this is open as .NET team can decided if this is by design

  3. transferred this issue fromdotnet/aspnetcoreon Nov 30, 2023
  4. ghost added
    untriaged
    on Nov 30, 2023
  5. javiercn commented on Nov 30, 2023

    @javiercn
    Member
  6. added
    arch-wasm
    on Nov 30, 2023
  7. lewing commented on Nov 30, 2023

    @lewing
    Member
  8. baronfel commented on Nov 30, 2023

    @baronfel
    Member

    @lewing what kind of dependencies does the packaged node in the wasm tools workloads have from the OS perspective? We could ask the @dotnet/dotnet-docker-contrib team to consider adding those to the SDK base image.

  9. lewing commented on Nov 30, 2023

    @lewing
    Member

    based on the issue here we're just missing libatomic it does seem a little odd that the packaged node isn't pulling it in. @directhex and ideas?

  10. directhex commented on Nov 30, 2023

    @directhex
    Contributor

    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).

  11. lbussell commented on Dec 7, 2023

    @lbussell
    Member

    @directhex, this only applies to .NET 8, right? And does this mean that the dependency on libatomic1 could change depending on which distro we're running on (due to different versions of Clang/GCC/Node)? I don't follow this completely - where are we building our own version of Clang or Node?

  12. directhex commented on Dec 7, 2023

    @directhex
    Contributor
  13. Sina-Soltani commented on Jan 31, 2024

    @Sina-Soltani

    Is this issue solved?
    I have the similar issue when I'm trying to use Docker and publish the Blazor Web Assembly project which is using .NET8.

    This is the error when I'm using the dotnet publish command:

     You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
    

    I tried to add the bellow command to install the suggested dotnet global tool before using the dotnet publish.
    RUN dotnet workload install wasm-tools

    But then comes another error:

    RUN dotnet workload install wasm-tools
    RUN dotnet publish "MyShop.Client.App/MyShop.Client.App.csproj" -c Release --no-restore -o /app/publish /p:UseAppHost=false
     ---> Running in b2290bea9148
    MSBuild version 17.8.3+195e7f5a3 for .NET
      MyShop.Client.App -> /app/src/MyShop.Client.App/bin/Release/net8.0/MyShop.Client.App.dll
      MyShop.Client.App (Blazor output) -> /app/src/MyShop.Client.App/bin/Release/net8.0/wwwroot
      Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
      Optimizing assemblies for size. This process might take a while.
      Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
      Compiling native assets with emcc with -Oz. This may take a while ...
    /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/8.0.1/Sdk/WasmApp.Native.targets(366,5): error : Failed to compile /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/8.0.1/runtimes/browser-wasm/native/src/corebindings.c -> /app/src/MyShop.Client.App/obj/Release/net8.0/wasm/for-publish/corebindings.o [/app/src/MyShop.Client.App/MyShop.Client.App.csproj]
    /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/8.0.1/Sdk/WasmApp.Native.targets(366,5): error : unable to find python in $PATH [took 0.00s] [/app/src/MyShop.Client.App/MyShop.Client.App.csproj]
    /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/8.0.1/Sdk/WasmApp.Native.targets(366,5): error : Failed to compile /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/8.0.1/runtimes/browser-wasm/native/src/driver.c -> /app/src/MyShop.Client.App/obj/Release/net8.0/wasm/for-publish/driver.o [/app/src/MyShop.Client.App/MyShop.Client.App.csproj]
    /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/8.0.1/Sdk/WasmApp.Native.targets(366,5): error : unable to find python in $PATH [took 0.00s] [/app/src/MyShop.Client.App/MyShop.Client.App.csproj]
    /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/8.0.1/Sdk/WasmApp.Native.targets(366,5): error : Failed to compile /usr/share/dotnet/packs/Microsoft.NETCore.App.Runtime.Mono.browser-wasm/8.0.1/runtimes/browser-wasm/native/src/pinvoke.c -> /app/src/MyShop.Client.App/obj/Release/net8.0/wasm/for-publish/pinvoke.o [/app/src/MyShop.Client.App/MyShop.Client.App.csproj]
    /usr/share/dotnet/packs/Microsoft.NET.Runtime.WebAssembly.Sdk/8.0.1/Sdk/WasmApp.Native.targets(366,5): error : unable to find python in $PATH [took 0.00s] [/app/src/MyShop.Client.App/MyShop.Client.App.csproj]
    Error response from daemon: The command '/bin/sh -c dotnet publish "MyShop.Client.App/MyShop.Client.App.csproj" -c Release --no-restore -o /app/publish /p:UseAppHost=false' returned a non-zero code: 1
    
  14. directhex commented on Jan 31, 2024

    @directhex
    Contributor

    It's complaining it can't find python. Does your docker image include a python executable? Upstream behaviour with emsdk is to bundle Python on Windows and Mac, but rely on whatever's in the distribution image on Linux, and we followed that

  15. Sina-Soltani commented on Jan 31, 2024

    @Sina-Soltani

    It's complaining it can't find python. Does your docker image include a python executable? Upstream behaviour with emsdk is to bundle Python on Windows and Mac, but rely on whatever's in the distribution image on Linux, and we followed that

    I'm using the normal dotnet SDK that is suggested by Microsoft.
    Here is the complete Dockerfile:

    FROM mcr.microsoft.com/dotnet/sdk:8.0 AS publish
    RUN dotnet workload install wasm-tools
    WORKDIR /app/src
    COPY ["MyShop.Client.App/MyShop.Client.App.csproj", "MyShop.Client.App/"]
    RUN dotnet restore "MyShop.Client.App/MyShop.Client.App.csproj"
    COPY . .
    RUN dotnet publish "MyShop.Client.App/MyShop.Client.App.csproj" -c Release --no-restore -o /app/publish /p:UseAppHost=false
    
    FROM nginx as final
    COPY --from=publish /app/publish/wwwroot /usr/share/nginx/html
    COPY --from=publish ["app/src/MyShop.Client.App/nginx.conf", "/etc/nginx/"]
    
  16. directhex commented on Jan 31, 2024

    @directhex
    Contributor

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

  17. Sina-Soltani commented on Feb 1, 2024

    @Sina-Soltani

    The problem is solved.
    I was starting the docker image inside Jetbrains Rider by clicking on the green play button inside the Dockerfile.
    Somehow it leads to the issue that I've sent here.
    The solution was simply building the docker image using a command prompt or terminal.
    No Python or whatever packages were needed for dotnet publish. Just the dotnet/sdk:8.0 was enough.

  18. harveytriana commented on Feb 28, 2024

    @harveytriana

    Hi Sina - Can you share the Dockerfile with us. I work in Visual Studio, and I haven't found the solution to the issue.

  19. Sina-Soltani commented on Feb 28, 2024

    @Sina-Soltani

    Hi Sina - Can you share the Dockerfile with us. I work in Visual Studio, and I haven't found the solution to the issue.

    Hi, this is my Dockerfile:

    FROM nginx as runtime
    
    FROM mcr.microsoft.com/dotnet/sdk:8.0 AS publish
    WORKDIR /app/src
    COPY ["MyShop.Client.App/MyShop.Client.App.csproj", "MyShop.Client.App/"]
    RUN dotnet restore "MyShop.Client.App/MyShop.Client.App.csproj"
    COPY . .
    RUN dotnet publish "MyShop.Client.App/MyShop.Client.App.csproj" -c Release --no-restore -o /app/publish /p:UseAppHost=false
    
    FROM runtime as final
    COPY --from=publish /app/publish/wwwroot /usr/share/nginx/html
    COPY --from=publish ["app/src/MyShop.Client.App/nginx.conf", "/etc/nginx/"]
    
  20. added this to the 9.0.0 milestone on Apr 13, 2024
  21. removed
    untriaged
    on Apr 13, 2024
  22. lewing commented on Apr 13, 2024

    @lewing
    Member

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

  23. lbussell commented on Apr 15, 2024

    @lbussell
    Member

    @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 dotnet/dotnet-docker#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 dotnet/dotnet-docker#5033.

  24. locked and limited conversation to collaborators on May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-wasmarea-Build-mono

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions