我有一个 dotnet5 控制台应用程序,它位于解决方案中,并且依赖于其他同级项目。我使用 Visual Studio 工具创建了 Docker 文件,这是 Docker 文件:
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"]
构建映像没问题,它正常添加到我的本地映像注册表,但是当我尝试运行此映像并创建容器时,出现此错误:
<块引用>找不到任何兼容的框架版本 框架“Microsoft.AspNetCore.App”,版本“5.0.0”未找到。
您可以通过安装指定的框架来解决问题 和/或 SDK。