My Error in Logs Explorer when I deploy my App in Google Cloud>Workloads
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '3.1.0' was not found.
The following frameworks were found: 5.0.4 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
My Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk
COPY . /app
WORKDIR /app
RUN dotnet publish -c Release -o out
COPY /out .
ENTRYPOINT ["dotnet", "Test.dll"]
This is the code which is supposed to run
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
namespace Server
{
class Program
{
private static TcpListener tcpListener;
public static void Main(string[] args)
{
tcpListener = new TcpListener(IPAddress.Any, 26950);
tcpListener.Start();
tcpListener.BeginAcceptTcpClient(TCPConnectCallback, null);
Console.ReadKey();
}
private static void TCPConnectCallback(IAsyncResult _result)
{
TcpClient _client = tcpListener.EndAcceptTcpClient(_result);
tcpListener.BeginAcceptTcpClient(TCPConnectCallback, null);
}
}
}
Solution:
FROM mcr.microsoft.com/dotnet/sdk:3.1 WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "run"]
You are using latest image of sdk
which in this case is version 5.0.4
. You need to use it 3.1.0
as your application:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1
Try one of these Dockerfile:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster
WORKDIR /app
COPY ./bin/Debug/netcoreapp3.1 .
EXPOSE 80
ENV ASPNETCORE_URLS "http://*:80"
ENTRYPOINT ["dotnet", "Test.dll"]
or
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "Test.dll"]```
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.