Search code examples
.netdocker64-bitwine

How do I install .NET 4 in a Wine 64-bit prefix?


I'm trying to get a .NET application working on Windows in a Docker container and it requires .NET 4. I've gotten it working in 32-bit but I need 64-bit for the extra memory space. This is a specialized scientific application.

Here's the Dockerfile:

FROM ubuntu:16.04

# we need wget, bzip2, wine from winehq, 
# xvfb to fake X11 for winetricks during installation,
# and winbind because wine complains about missing 
# Prevents annoying debconf errors during builds
ARG DEBIAN_FRONTEND="noninteractive"
RUN dpkg --add-architecture i386 \
    && apt-get update \
    && apt-get install -y \
        software-properties-common \
        winbind \
        cabextract \
        p7zip \
        unzip \
        wget \
        zenity \
        xvfb && \
    apt-get -y clean && \
    rm -rf \
      /var/lib/apt/lists/* \
      /usr/share/doc \
      /usr/share/doc-base \
      /usr/share/man \
      /usr/share/locale \
      /usr/share/zoneinfo

ENV WINEDISTRO=staging
ENV WINEVERSION=3.12.0~xenial

# Install wine
RUN wget -nc https://dl.winehq.org/wine-builds/Release.key \
    && apt-key add Release.key \
    && apt-get update \
    && apt-get install -y apt-transport-https \
    && add-apt-repository https://dl.winehq.org/wine-builds/ubuntu/ \
    && apt-get update \
    && apt-get install -y --install-recommends winehq-$WINEDISTRO=$WINEVERSION wine-$WINEDISTRO=$WINEVERSION wine-$WINEDISTRO-i386=$WINEVERSION wine-$WINEDISTRO-amd64=$WINEVERSION && \
    apt-get -y clean && \
    rm -rf \
      /var/lib/apt/lists/* \
      /usr/share/doc \
      /usr/share/doc-base \
      /usr/share/man \
      /usr/share/locale \
      /usr/share/zoneinfo \
      && \
    wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks \
      -O /usr/local/bin/winetricks && chmod +x /usr/local/bin/winetricks

# put C:\pwiz on the Windows search path
ENV WINEARCH win64
ENV WINEDEBUG -all,err+all

# To be singularity friendly, avoid installing anything to /root
RUN mkdir -p /wineprefix64/
ENV WINEPREFIX /wineprefix64
WORKDIR /wineprefix64

# wineserver needs to shut down properly!!! 
ADD waitonprocess.sh /wineprefix64/waitonprocess.sh
RUN chmod +x waitonprocess.sh

# Install dependencies
RUN winetricks -q win7 && xvfb-run winetricks -q dotnet45 && ./waitonprocess.sh wineserver

I've tried WINE and 3.13, 3.12, 3.11, 3.10, 3.9, with pretty much the same results. If I install on a clean prefix I actually get an error quite fast:

Step 4/47 : FROM ubuntu:16.04
Step 19/47 : ARG DEBIAN_FRONTEND="noninteractive"
Step 20/47 : RUN dpkg --add-architecture i386     && apt-get update     && apt-get install -y         software-properties-common         winbind         cabextract         p7zip         unzip         wget         zenity         xvfb &&     apt-get -y clean &&     rm -rf       /var/lib/apt/lists/*       /usr/share/doc       /usr/share/doc-base       /usr/share/man       /usr/share/locale       /usr/share/zoneinfo
Step 21/47 : ENV WINEDISTRO=staging
Step 22/47 : ENV WINEVERSION=3.13.0~xenial
Step 23/47 : RUN wget -nc https://dl.winehq.org/wine-builds/Release.key     && apt-key add Release.key     && apt-get update     && apt-get install -y apt-transport-https     && add-apt-repository https://dl.winehq.org/wine-builds/ubuntu/     && apt-get update     && apt-get install -y --install-recommends winehq-$WINEDISTRO=$WINEVERSION wine-$WINEDISTRO=$WINEVERSION wine-$WINEDISTRO-i386=$WINEVERSION wine-$WINEDISTRO-amd64=$WINEVERSION &&     apt-get -y clean &&     rm -rf       /var/lib/apt/lists/*       /usr/share/doc       /usr/share/doc-base       /usr/share/man       /usr/share/locale       /usr/share/zoneinfo       &&     wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks       -O /usr/local/bin/winetricks && chmod +x /usr/local/bin/winetricks
Step 24/47 : ENV WINEARCH win64
Step 25/47 : ENV WINEDEBUG -all,err+all
Step 28/47 : RUN mkdir -p /wineprefix64/
Step 29/47 : ENV WINEPREFIX /wineprefix64
Step 30/47 : WORKDIR /wineprefix64
Step 31/47 : ADD waitonprocess.sh /wineprefix64/waitonprocess.sh
Step 32/47 : RUN chmod +x waitonprocess.sh
Step 34/47 : RUN xvfb-run winetricks -q dotnet45 && ./waitonprocess.sh wineserver
 ---> Running in c0f8d76792c5
------------------------------------------------------
Running Wine/winetricks as root is highly discouraged. See https://wiki.winehq.org/FAQ#Should_I_run_Wine_as_root.3F
------------------------------------------------------
------------------------------------------------------
wine cmd.exe /c echo '%ProgramFiles%' returned unexpanded string '%ProgramFiles%' ... this can be caused by a corrupt wineprefix, by an old wine, or by not owning /wineprefix64
------------------------------------------------------
The command '/bin/sh -c xvfb-run winetricks -q dotnet45 && ./waitonprocess.sh wineserver' returned a non-zero code: 1

If I install an OS version first then it goes much further and hangs at the end. wine-staging-3.12-amd64-win7-dotnet45 build log

The 3.13 results are very similar. It ends up the same way. I've done a lot of searching and almost everything is about how to get it working for 32-bit stuff. The few 64-bit threads I've seen don't give enough detail about HOW to get .NET 4 installed manually.


Solution

  • I discovered the problem was that I was using winehq-staging instead of winehq-devel. With winehq-devel=3.12.0~xenial, the dotnet40 verb in winetricks works. Actually even the dotnet472 verb works now with the latest version.