Answers: <p>Move the WORKDIR &quot;/src/FACTS_SendMail&quot; line right above the &quot;COPY . .&quot; 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.</p>
  
Answers: CC BY-SA 4.0
Answers: 2023-04-15T07:35:05.723Z
Answers: 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!!!
Answers: Hayen
Answers: CC BY-SA 4.0
Answers: 2023-04-14T03:29:26.513Z
Answers: 2023-04-14T03:30:29.727Z
Answers: 2023-04-14T03:30:29.727Z
Answers: Rudy Chakraborty
Body: <p>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:</p>
  <p><strong>CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point.</strong></p>
  <p>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.</p>
  <p>Any assistance would be greatly appreciated.</p>
  <pre><code>FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
  WORKDIR /app
  EXPOSE 80
  EXPOSE 443
  
  FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
  WORKDIR /src
  #COPY [&quot;FACTS_SendMail/FACTS_SendMail.csproj&quot;, &quot;FACTS_SendMail/&quot;]
  COPY [&quot;/FACTS_SendMail.csproj&quot;, &quot;FACTS_SendMail/&quot;]
  RUN dotnet restore &quot;FACTS_SendMail/FACTS_SendMail.csproj&quot;
  COPY . .
  WORKDIR &quot;/src/FACTS_SendMail&quot;
  RUN dotnet build &quot;FACTS_SendMail.csproj&quot; -c Release -o /app/build
  
  FROM build AS publish
  RUN dotnet publish &quot;FACTS_SendMail.csproj&quot; -c Release -o /app/publish /p:UseAppHost=false
  
  FROM base AS final
  WORKDIR /app
  COPY --from=publish /app/publish .
  ENTRYPOINT [&quot;dotnet&quot;, &quot;FACTS_SendMail.dll&quot;]
  </code></pre>
  
Tags: <docker><azure-devops><containers><azure-pipelines><windows>
Title: Azure DevOps Pipeline failure - Program does not contain a static 'Main' method suitable for an entry point
UserDisplayName: Hayen
ThreadText: # Azure DevOps Pipeline failure - Program does not contain a static 'Main' method suitable for an entry point
  
  (Asked by: username_0 on 2023-04-04)
  
  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
  WORKDIR /app
  EXPOSE 80
  EXPOSE 443
  
  FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
  WORKDIR /src
  #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
  WORKDIR /app
  COPY --from=publish /app/publish .
  ENTRYPOINT ["dotnet", "FACTS_SendMail.dll"]
  
  ```
  
  **Tags:** docker, azure-devops, containers, azure-pipelines, windows
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-04-14. Score: 2
  
  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.
  
  > **Comments:**
  > **username_0**: 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!!!  
  
  ---
  
  