C
C#3y ago
kampfmodz

Docker build failing

Hey so i am getting CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [project] when running the dockerfile which i generated with VS. I am using .net 6.
15 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
kampfmodz
kampfmodzOP3y ago
there is no static Main in the code since its dotnet 6
Auger
Auger3y ago
Show the Dockerfile as well as the entry point in your code
kampfmodz
kampfmodzOP3y ago
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
WORKDIR /app

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

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

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "VidGrab.DatabaseIndexer.dll"]
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
WORKDIR /app

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

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

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "VidGrab.DatabaseIndexer.dll"]
i got no entry point i just start right into it
Auger
Auger3y ago
Even if it's a top-level program, it has an implicit main-method in that file, just compiled behind the scenes. Every program needs an entry point Show the code where you expect your program to start executing from The dockerfile looks right to me
kampfmodz
kampfmodzOP3y ago
Auger
Auger3y ago
Delete that entire line at the top of that screenshot The code will start executing on the line with try now (assuming what you've shown is the Program.cs)
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
kampfmodz
kampfmodzOP3y ago
still the same what do you mean ?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Auger
Auger3y ago
Can you show the whole file?
Auger
Auger3y ago
This looks like a correct top-level entrypoint
kampfmodz
kampfmodzOP3y ago
ok so an docker problem ?
Auger
Auger3y ago
Sounds like more a compile-time issue. Are you sure it's building your docker image?
Want results from more Discord servers?
Add your server