简体   繁体   English

Kubernetes 找不到兼容版本(dotnet)

[英]Kubernetes no compatible version found (dotnet)

My Error in Logs Explorer when I deploy my App in Google Cloud>Workloads当我在 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.找不到框架“Microsoft.NETCore.App”,版本“3.1.0”。

The following frameworks were found: 5.0.4 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]找到以下框架:5.0.4 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.您可以通过安装指定的框架和/或 SDK 来解决问题。

The specified framework can be found at:可以在以下位置找到指定的框架:

https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.0&arch=x64&rid=debian.10-x64 https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.0&arch=x64&rid=debian.10-x64

My Dockerfile:我的 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 .您正在使用sdk的最新图像,在这种情况下是版本5.0.4 You need to use it 3.1.0 as your application:您需要将其3.1.0用作您的应用程序:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1

Try one of these Dockerfile:尝试以下 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"]```

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM