Windows Docker:在 Windows Docker 中安装 Visual C++ Redistributable 时出现问题

iss*_*swf 3 c# dependencies vcredist docker dockerfile

对此完全陌生..使用.net 6.0。

尝试将 vc_redist.x64 安装到 Windows docker 中以使用命令行界面运行 Windows exe。在网上搜索后发现这个添加到docker文件中,但是redist没有安装(尽管构建输出显示该RUN vc_redist.x64.exe /install /quiet /norestart /log vc_redist.log行执行没有错误,但我也无法运行exe。在docker映像上,我找不到将是的dll与 vc_redist 关联。我做错了什么?

FROM mcr.microsoft.com/windows/servercore:ltsc2019
ADD https://aka.ms/vs/16/release/vc_redist.x64.exe vc_redist.x64.exe
RUN vc_redist.x64.exe /install /quiet /norestart /log vc_redist.log    

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Directory/Project1.csproj", "Project1/"]
RUN dotnet restore "Directory/Project1.csproj"
COPY . .
WORKDIR "/src/Directory"
RUN dotnet build "Project1.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Project1.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Project1.dll"]
Run Code Online (Sandbox Code Playgroud)

Mat*_*ser 8

我发现我可以使用以下代码将其安装到 Docker 映像上:

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
    Invoke-WebRequest "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile "vc_redist.x64.exe"; `
    Start-Process -filepath C:\vc_redist.x64.exe -ArgumentList "/install", "/passive", "/norestart" -Passthru | Wait-Process; `
    Remove-Item -Force vc_redist.x64.exe;
Run Code Online (Sandbox Code Playgroud)

来源: https: //github.com/microsoft/dotnet-framework-docker/issues/15