且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Docker在VS中运行,但发布到AWS时出错?错误CS5001:程序不包含适用于入口点的静态“ Main”方法

更新时间:2023-11-13 18:50:34

构建阶段中的路径很奇怪。您的项目文件将被复制到子文件夹 / src / ProcessFiles ,但是源文件将被复制到 / src 。在复制之前设置 WORKDIR 应该可以使它们放到正确的位置。

The pathing in your build phase is wonky. Your project file is being copied to the subfolder /src/ProcessFiles, but the source files are being copied to /src. Setting the WORKDIR before copying should allow them to land in the right place.

FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY ProcessFiles.csproj ProcessFiles/
RUN dotnet restore ProcessFiles/ProcessFiles.csproj
WORKDIR /src/ProcessFiles
COPY . .
RUN dotnet build ProcessFiles.csproj -c Release -o /app