I'm trying to create a dotnet core application and deploy it to a kubernetes cluster through azure yaml pipelines (with multiple repositories)
I'm hitting the following error:
CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [/src/File.Pod/File.Pod.csproj]
The project was created with this command : dotnet new console -o File.Pod-n File.Pod
My Goal is to deploy an exe. Most of documentations on Internet talks about deployment ASPNET web applications.
csproj generated
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
**<OutputType>Exe</OutputType>**
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="3.1.7" />
<PackageReference Include="Models" Version="9704.0.0-beta" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.9.3" />
<PackageReference Include="Utils.Log" Version="2020.9.3.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared.Lib\File.Service\File.Service.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Helpers\" />
</ItemGroup>
</Project>
And the docker file:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY ["File.Pod.csproj", "File.Pod/"]
COPY ["Shared.Lib/File.Service/File.Service.csproj", "Shared.Lib/File.Service/"]
COPY ["Shared.Lib/File.DAL/File.DAL.csproj", "Shared.Lib/File.DAL/"]
COPY ["nuget.config", "./"]
RUN dotnet restore "File.Pod/File.Pod.csproj" --configfile nuget.config -nowarn:msb3202,nu1503 --verbosity diag
COPY . .
WORKDIR "/src/File.Pod"
RUN dotnet build "File.Pod.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "File.Pod.csproj" -c Release -o /app
FROM build AS base
RUN apt update && apt install -y openssh-client
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "run"]
As ENTRYPOINT, I tried ENTRYPOINT ["dotnet", "run"] or ENTRYPOINT ["dotnet", "File.POD.DLL"] with no difference.
I feel that the problem is with the type of images ( FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build) , but I'm unsure. I tried various ones with same result.
Exact error log:
2020-09-11T11:05:41.9723837Z Step 10/26 : RUN dotnet build "File.Pod.csproj" -c Release -o /app
2020-09-11T11:05:42.0083655Z ---> Running in 7ed9311b9c89
2020-09-11T11:05:42.7118936Z Microsoft (R) Build Engine version 16.6.0+5ff7b0c9e for .NET Core
2020-09-11T11:05:42.7119408Z Copyright (C) Microsoft Corporation. All rights reserved.
2020-09-11T11:05:42.7119642Z
2020-09-11T11:05:43.1438745Z Determining projects to restore...
2020-09-11T11:05:45.6330496Z Restored /src/File.Pod/File.Pod.csproj (in 2.04 sec).
2020-09-11T11:05:45.6330978Z Restored /src/Shared.Lib/File.Service/File.Service.csproj (in 2.05 sec).
2020-09-11T11:05:45.7516552Z Restored /src/Shared.Lib/File.DAL/File.DAL.csproj (in 101 ms).
2020-09-11T11:05:49.6118355Z File.DAL -> /app/File.DAL.dll
2020-09-11T11:05:50.2378452Z File.Service -> /app/File.Service.dll
2020-09-11T11:05:50.6394251Z CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [/src/File.Pod/File.Pod.csproj]
2020-09-11T11:05:50.6525494Z
2020-09-11T11:05:50.6525914Z Build FAILED.
2020-09-11T11:05:50.6531013Z
2020-09-11T11:05:50.6536286Z CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [/src/File.Pod/File.Pod.csproj]
2020-09-11T11:05:50.6541921Z 0 Warning(s)
2020-09-11T11:05:50.6542199Z 1 Error(s)