I have .NET 5 app, but a lot of project dependencies are still in .NET Framework 4.7.2 world…
I need to dockerize this app (for Windows Containers for now – this is the first step), but copying C:Program Filesdotnet
from mcr.microsoft.com/dotnet/framework/sdk:4.8
image into mcr.microsoft.com/dotnet/sdk:5.0
did not change anything and I still cannot build csproj file.
My Dockerfile:
FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 AS framework-sdk
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
# Copy the .NET Framework from framework-sdk image
ENV DOTNET_PATH="C:Program Filesdotnet"
COPY --from=framework-sdk ${DOTNET_PATH} ${DOTNET_PATH}
WORKDIR /src
RUN dotnet restore (...)
COPY . .
WORKDIR (...)
FROM build AS publish
RUN dotnet publish "xx.csproj" -c Release -o /app/publish --no-restore
I also tried to install chocolatey to install .NET Framework SDK, but choco needs .NET Framework 4.0…
And I can’t install .NET Framework -> RUN pwsh -Command Install-WindowsFeature .NET-Framework-45-Features
gives me error:
The term 'Install-WindowsFeature' is not recognized
…
Please note that pwsh
is PoweShell Core. And even if I will install .NET Framework 4.0/4.5 I still need to "restart" machine.
Do you have some suggestions or maybe there are some docker images with .NET Framework and .NET 5 runtime and .NET Framework SDK and .NET 5 SDK?
Source: Windows Questions