Windows Docker: Issues installing Visual C++ Redistributable in Windows Docker
Asked Answered
B

1

6

Totally new to this.. Using .net 6.0.

trying to install a vc_redist.x64 into windows docker to run a windows exe with command line interface. Searching around online came up with this to add to docker file, but the redist isn't installed (event though build output shows that RUN vc_redist.x64.exe /install /quiet /norestart /log vc_redist.log line executed without errors, nor can I run the exe. On docker image I cant find the dlls that would be associated with vc_redist. What am I doing wrong?

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"]
Balladry answered 21/2, 2022 at 17:53 Comment(0)
B
11

I found I was able to install this onto a docker image with the following code:

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;

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

Bernat answered 5/9, 2022 at 15:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.