mikejos
mikejos

Reputation: 71

Blazor .NET 6 with Native Dependency cannot build as a Docker image

I want to add a native dependency to my Docker hosted Blazor Web Assembly application, but cannot build the Docker image, even though the application builds and runs perfectly well outside of Docker.

Below are steps that replicate the issue.

  1. In Visual Studio 2022 create a default .NET 6 Blazor Web Assembly application

  2. Add Docker support to the project

  3. Edit the project file to require native linking, by adding the following line to <PropertyGroup> - <WasmBuildNative>True</WasmBuildNative>

  4. Add a line to the Dockerfile to install the WASM tools - RUN dotnet workload install wasm-tools

  5. Try to build the Docker image - 'Error: The command "emcc --version" exited with code 1.'

No other error details are provided.

Upvotes: 0

Views: 635

Answers (1)

Hans Kilian
Hans Kilian

Reputation: 25622

Emscripten, which is used to do the compilation, requires python which isn't installed in the SDK image.

You can install it yourself in the build image by adding the line

RUN apt-get update && apt-get install -y python3

in your Dockerfile, somewhere before you do your dotnet build or publish.

Upvotes: 1

Related Questions