3

I have a dotnet5 Console application that is inside a solution and has dependencies on other sibling projects. I create the Docker file with visual studio tools and this is the Docker file:

FROM mcr.microsoft.com/dotnet/runtime:5.0-buster-slim AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
WORKDIR /src
COPY ["src/MyProject/MyProject.Launcher/MyProject.Launcher.csproj", "src/MyProject/MyProject.Launcher/"]
COPY ["src/MyProject/MyProject.DataAccess/MyProject.DataAcess.csproj", "src/MyProject/MyProject.DataAccess/"]
COPY ["src/MyProject/MyProject.Service/MyProject.Service.csproj", "src/MyProject/MyProject.Service/]
COPY ["src/Domain/MyProject.Domain.Model/MyProject.Domain.Model.csproj", "src/Domain/MyProject.Domain.Model/"]
RUN dotnet restore "src/MyProject/MyProject.Launcher/MyProject.Launcher.csproj"
COPY . .
WORKDIR "/src/src/MyProject/MyProject.Launcher"
RUN dotnet build "MyProject.Launcher.csproj" -c Release -o /app/build

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

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyProject.Launcher.dll"]

building image is ok and it added normally to my local image registry but when I try to run this image and create a container I am getting this error:

It was not possible to find any compatible framework version The framework 'Microsoft.AspNetCore.App', version '5.0.0' was not found.

  • No frameworks were found.

You can resolve the problem by installing the specified framework and/or SDK.

Navid_pdp11
  • 3,487
  • 3
  • 37
  • 65

2 Answers2

5

Use this as your base image:

FROM mcr.microsoft.com/dotnet/aspnet:5.0.0-buster-slim AS base

StefanFFM
  • 1,526
  • 1
  • 14
  • 25
1

I Think You should check docker hub and search for .NET 5 SDK then install that image on your container then its will be fixed :

enter image description here

I Found Dotnet 3.1 SDK but try to find dotnet 5 SDK

I think after installation this error will be fix

Sorry For my Bad English

:)

Ramin Azali
  • 198
  • 11