Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Docker: Issues installing Visual C++ Redistributable in Windows Docker

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"]
like image 295
isswf Avatar asked Sep 04 '26 17:09

isswf


1 Answers

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

like image 189
Matthew Dresser Avatar answered Sep 06 '26 07:09

Matthew Dresser



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!