I have been tasked with deploying an email service to an Azure tenant using Windows Containers. In my Pipeline (Azure DevOps), I am receiving the following error when in the build step:

CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point.

I believe my docker file is not correct. It was autogenerated from VS2022 and it doesn't resemble the docker files I've used in the past. Also, the Repo is TFVC.

Any assistance would be greatly appreciated.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
#COPY ["FACTS_SendMail/FACTS_SendMail.csproj", "FACTS_SendMail/"]
COPY ["/FACTS_SendMail.csproj", "FACTS_SendMail/"]
RUN dotnet restore "FACTS_SendMail/FACTS_SendMail.csproj"
COPY . .
WORKDIR "/src/FACTS_SendMail"
RUN dotnet build "FACTS_SendMail.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "FACTS_SendMail.csproj" -c Release -o /app/publish /p:UseAppHost=false

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

1 Answer 1


Move the WORKDIR "/src/FACTS_SendMail" line right above the "COPY . ." line. This solved the issue for me. Apparently setting the working directory before helps in copying the restored packages from dotnet restore to the right place. Not sure I understand it fully but fixed it for me.

  • That was it!!! Now that I look at it, it makes a lot of sense as to the order not the specific error. The deploy failed but I expected that because Access Denied. Thank you for your help!!!
    – Hayen
    Apr 15, 2023 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.