I have a .NET Core 3.1.3 Web API project that is built as x86. It has to be x86 because it makes use of an x86 C++ DLL via dllimport. Outside of Docker the application runs as expected. However, it fails immediately as soon as I add Windows Docker support. I believe from SO research that it fails because Microsoft does not provide any x86 base image for .NET Core. The default Windows Docker base image is currently mcr.microsoft.com/dotnet/core/aspnet:3.1-nanoserver-1903.
I’ve tried using mcr.microsoft.com/windows/servercore:1909 as the base image, but I then get an error saying “Unable to start program: ‘C:Program Filesdotnetdotnet.exe.'” I assume this is because this exe does not exist on the base image used. And, presumably for x86 “C:Program Files (x86)dotnetdotnet.exe” would actually be required.
My current Dockerfile is:
FROM mcr.microsoft.com/windows/servercore:1909 AS base WORKDIR /app EXPOSE 80 EXPOSE 443 FROM mcr.microsoft.com/windows/servercore:1909 AS build WORKDIR /src COPY ["WAPTCoreWebService/WAPTCoreWebService.csproj", "WAPTCoreWebService/"] RUN dotnet restore "WAPTCoreWebService/WAPTCoreWebService.csproj" COPY . . WORKDIR "/src/WAPTCoreWebService" RUN dotnet build "WAPTCoreWebService.csproj" -c Release -o /app/build FROM build AS publish RUN dotnet publish "WAPTCoreWebService.csproj" -c Release -o /app/publish FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "WAPTCoreWebService.dll"]
Am I interpreting this error correctly. If not, what does it mean? If so, how do I add support to build an x86 version of my .NET Core app in this image? Do I need to download and run dotnet-runtime-3.1.3-win-x86.exe somehow? If so, how?