无法计算缓存键:找不到“.csproj”
我是 Docker 的新手。我使用 ASP.Net Core 使用 Visual Studio 2019 以及 VS Code 创建了一个 Web API。它工作正常。然后我添加了 docker 支持并添加了具有默认值的 Dockerfile。
当我尝试构建 docker 映像时,它在 Visual Studio 2019 和 VS Code 中都失败了。
但是,如果我尝试使用 Visual Studio 2019 提供的选项(我可以选择 docker 作为运行)运行 Docker 映像,则会创建该映像。但是当我在 Visual Studio 2019 或 VS Code 中运行 build 命令时,即
docker build -f ./Dockerfile --force-rm -t mytestapp:dev ..
it throws following error<br>
=> ERROR [build 3/7] COPY [myTestApp.csproj, ./]
Content of my docker file is given below
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["myTestApp.csproj", "./"]
RUN dotnet restore "myTestApp.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "myTestApp.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "myTestApp.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "myTestApp.dll"]
还附上项目结构图: