Google App Engine Logs "The specified framework 'Microsoft.AspNetCore.App', version '2.1.1' was



在Google App Engine Flexible上运行我的.net Core 3.1服务时,我定期收到一系列错误,这些错误表面上与服务调用无关:

  • "找不到指定的框架'Microsoft.AspNetCore.App',版本'2.1.1'。">
  • 找到了以下框架:
  • 3.0.1 at [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]

这些错误大约每 3-4 分钟记录一次 - 无论是否调用服务。

开发和运行时:

  • Windows 上的 Visual Studio 2019 具有 1 个 webapi 服务项目 (/api/values( 和一个 docker-compose 项目
  • .Net Core 3.1
  • Docker linux 容器
  • 谷歌应用引擎灵活

我已经阅读了几篇关于此类错误的文章,但就我而言,我没有任何 2.1.1 参考或代码。我的目标是.net核心3.1。我该如何解决?

当我在本地"dotnet run"或"docker run"时不会发生错误。它们仅出现在 GAE 环境中。GAE 是否依赖于 2.1.1?或者 3.1.1 不"支持">

我尝试过针对多框架,但这会在应用程序中产生各种引用问题。无论如何,该服务都能正常运行。另一方面,查看错误日志的同事将把它用作与服务相关的任何和所有问题的替罪羊。

那么问题出在解决方案、dockerfile 还是 GAE 中?

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
# EXPOSE 80
# EXPOSE 443
EXPOSE 8080
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
ADD dev-certificate.pfx /usr/local/share/ca-certificates/dev-certificate.crt
RUN update-ca-certificates
COPY Xxxxx.Orchestrations.Cost/Xxxxx.Orchestrations.Cost.csproj Xxxxx.Orchestrations.Cost/
RUN dotnet restore "Xxxxx.Orchestrations.Cost/Xxxxx.Orchestrations.Cost.csproj"
COPY . .
WORKDIR "/src/Xxxx.Orchestrations.Cost"
RUN dotnet build "Xxxxx.Orchestrations.Cost.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Xxxxx.Orchestrations.Cost.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
# CMD chmod /app/publish/dev-certificate.pfx +rrr

# ENV ASPNETCORE_ENVIRONMENT=Development
ENV ASPNETCORE_URLS=http://*:8080;https://*:443
ENV ASPNETCORE_HTTPS_PORT=443
ENV ASPNETCORE_Kestrel__Certificates__Default__Path=dev-certificate.pfx
ENV ASPNETCORE_Kestrel__Certificates__Default__Password=ufo
ENTRYPOINT ["dotnet", "Xxxxx.Orchestrations.Cost.dll"]

app.yaml

runtime: custom
env: flex

# This sample incurs costs to run on the App Engine flexible environment.
# The settings below are to reduce costs during testing and are not appropriate
# for production use. For more information, see:
# https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
network:
name: default
subnetwork_name: default-us-east1
service: get-cost
env_variables:
# The __ in My__Greeting will be translated to a : by ASP.NET.
My__Greeting: Hello AppEngine Flex!

此方案中的罪魁祸首是 ConfigureServices 方法中 StartUp 类的一行样板 VS 代码:

services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);

将代码更改为

services.AddMvc(); 

删除了 Google 应用引擎日志中的错误消息。

相关内容

最新更新