I have a problem using docker and couldn't find a suitable solution.
I am trying to create a docker image using dotnet sdk 3.1
The thing is, when the docker tries to execute the build statement, it fails and the error output is
CSC: error CS5001: the program does not contain a suitable static 'main' method for an entry point
Here my Dockerfile:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["Mail.StateMachine.csproj", "statemachine/"]
RUN dotnet restore "statemachine/Mail.StateMachine.csproj"
WORKDIR "/src/statemachine"
COPY . .statemachine
RUN dotnet build "Mail.StateMachine.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Mail.StateMachine.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Mail.StateMachine.dll"]
Here the Main Method
public static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.Console()
.CreateLogger();
try
{
Log.Information("Starting web host");
CreateHostBuilder(args).Build().Run();
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly");
}
finally
{
Log.CloseAndFlush();
}
}