如何在 Wine 64 位前缀中安装 .NET 4?

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

我正在尝试让一个 .NET 应用程序在 Docker 容器中的 Windows 上运行,它需要 .NET 4。我已经让它在 32 位上运行,但我需要64 位用于额外内存 space。这是一个专门的科学应用程序。

这是 Docker 文件:

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

我试过 WINE 和 3.13、3.12、3.11、3.10、3.9,结果几乎相同。如果我安装在一个干净的前缀上,我实际上很快就会得到一个错误:

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

如果我先安装 OS 版本,那么它会走得更远并在最后挂起。 wine-staging-3.12-amd64-win7-dotnet45 build log

3.13的结果非常相似。它以同样的方式结束。我做了很多搜索,几乎所有内容都是关于如何让它适用于 32 位的东西。我见过的几个 64 位线程没有提供足够的关于如何手动安装 .NET 4 的详细信息。

我发现问题是我使用的是 winehq-staging 而不是 winehq-devel。使用 winehq-devel=3.12.0~xenial,winetricks 中的 dotnet40 动词起作用。实际上,即使是 dotnet472 动词现在也可以使用最新版本。