I’m trying to run Blazor WebAssembly Application in docker. I create an symple project in IDE.
I create a standard docker file.
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["BlazorApp1/BlazorApp1.csproj", "BlazorApp1/"]
RUN dotnet restore "BlazorApp1/BlazorApp1.csproj"
COPY . .
WORKDIR "/src/BlazorApp1"
RUN dotnet build "BlazorApp1.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "BlazorApp1.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "BlazorApp1.dll"]
I always get the error:
The command could not be loaded, possibly because:
2024-09-07T15:35:29.901357995Z * You intended to execute a .NET application:
2024-09-07T15:35:29.901359906Z The application '/app/../../../.nuget/packages/microsoft.aspnetcore.components.webassembly.devserver/7.0.20/tools/blazor-devserver.dll' does not exist.
2024-09-07T15:35:29.901463695Z * You intended to execute a .NET SDK command:
2024-09-07T15:35:29.901473592Z No .NET SDKs were found.
2024-09-07T15:35:29.901474891Z
2024-09-07T15:35:29.901475867Z Download a .NET SDK:
2024-09-07T15:35:29.901476809Z https://aka.ms/dotnet/download
2024-09-07T15:35:29.901477742Z
2024-09-07T15:35:29.901478621Z Learn about SDK resolution:
2024-09-07T15:35:29.901479730Z https://aka.ms/dotnet/sdk-not-found
Tried this method:
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /app
COPY Locator.sln ./
COPY ./Locator/Locator.csproj ./Locator/
RUN dotnet workload install wasm-tools
RUN dotnet restore ./Locator/Locator.csproj
COPY . ./
RUN dotnet ef --version
RUN apt-get update && apt-get install -y python3
RUN dotnet publish ./Locator/Locator.csproj -c Release -o out
FROM nginx:1.23.0-alpine
WORKDIR /app
EXPOSE 8080
COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=build /app/out/wwwroot /usr/share/nginx/html
I get an error:
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
2024-09-07 18:49:14 Could not execute because the specified command or file was not found.
2024-09-07 18:49:14 Possible reasons for this include:
2024-09-07 18:49:14 * You misspelled a built-in dotnet command.
2024-09-07 18:49:14 * You intended to execute a .NET program, but dotnet-/app/../../../.nuget/packages/microsoft.aspnetcore.components.webassembly.devserver/7.0.17/tools/blazor-devserver.dll does not exist.
2024-09-07 18:49:14 * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Issue with run docker image for Blazor WebAssembly App
I saw that. It doesn’t help.
1