All 21.X versions prior to 21.1 doesn't depend on ASP .NET Core runtime but since 21.2 it does and I have this error below because I just use .NET runtime in docker. That's not critical but I want to run long pooling bot in docker so I don't need whole asp .net core image but I have to use it because of that dependency
Steps to reproduce
Create any non ASP .NET Core project (console, hosted worker service and etc) with name SampleProject and reference Telegram.Bot version higher or equal to 21.2.0
3, Create Dockerfile in project directory where we use simple .NET runtime
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
USER app
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["SampleProject/nuget.config", "SampleProject/"]
COPY ["SampleProject/SampleProject.csproj", "SampleProject/"]
RUN dotnet restore "./SampleProject/SampleProject.csproj"
COPY . .
WORKDIR "/src/SampleProject"
RUN dotnet build "./SampleProject.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./SampleProject.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "SampleProject.dll"]
4. Build and run Docker image
docker build --tag sample -f ./SampleProject/Dockerfile .
docker run sample
5. Get error message that you should use ASP .NET Core framework
You must install or update .NET to run this application.
All 21.X versions prior to 21.1 doesn't depend on ASP .NET Core runtime but since 21.2 it does and I have this error below because I just use .NET runtime in docker. That's not critical but I want to run long pooling bot in docker so I don't need whole asp .net core image but I have to use it because of that dependency
Steps to reproduce
SampleProject
and referenceTelegram.Bot
version higher or equal to21.2.0
3, Create Dockerfile in project directory where we use simple .NET runtime
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src COPY ["SampleProject/nuget.config", "SampleProject/"] COPY ["SampleProject/SampleProject.csproj", "SampleProject/"] RUN dotnet restore "./SampleProject/SampleProject.csproj" COPY . . WORKDIR "/src/SampleProject" RUN dotnet build "./SampleProject.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish ARG BUILD_CONFIGURATION=Release RUN dotnet publish "./SampleProject.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "SampleProject.dll"]
docker build --tag sample -f ./SampleProject/Dockerfile . docker run sample
You must install or update .NET to run this application.
App: /app/SampleProject.dll Architecture: x64 Framework: 'Microsoft.AspNetCore.App', version '8.0.0' (x64) .NET location: /usr/share/dotnet/
No frameworks were found.
Learn more: https://aka.ms/dotnet/app-launch-failed
To install missing framework, download: https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=8.0.0&arch=x64&rid=linux-x64&os=debian.12