在 Google 云 Shell 中构建 .NET Core 2.1 应用程序失败

Building .NET Core 2.1 app fails in Google Cloud Shell

我已经创建了一个 ASP.NET 核心 2.1 应用程序,我正试图将其部署到 Google 云平台。它在本地使用 dotnet build 构建得很好。

不过,我无法通过 Google 云 Shell 构建它。 运行 dotnet --version 确认 Google Cloud Shell 已安装 .NET Core 2.0

运行 gcloud app deploy 启动了应用程序的部署,但我从日志中收到一个神秘的错误:

Step #0: Status: Downloaded newer image for gcr.io/gcp-runtimes/aspnetcorebuild@sha256:ad1b788a9b4cca75bb61eb523ef358ca059c4bd208fba15a10ccc6acab83f49a

Step #0: No .deps.json file found for the app Finished Step #0

ERROR: build step 0 "gcr.io/gcp-runtimes/aspnetcorebuild@sha256:ad1b788a9b4cca75bb61eb523ef358ca059c4bd208fba15a10ccc6acab83f49a" failed: exit status 1

我的印象是 GCP 默认支持 .NET Core 2.1 容器,所以我没有包含 Docker 文件.

我正在尝试部署到 flexible 环境,这是我的 app.yaml 文件:

runtime: aspnetcore
env: flex

我需要创建自定义 Docker 容器吗?或者是否有其他方法可以在 Google Cloud Shell 中获得对 .NET Core 2.1 的支持?

编辑: 现在我已经在 shell 本地安装 Google Cloud Tools 到 运行 gcloud app deploy 运行宁dotnet publish.

请记住,Microsoft 在 dotnet 核心映像上从 aspnetcore 切换到 dotnet。
https://hub.docker.com/r/microsoft/dotnet/

我试图重现它 - 实际上,Cloud Shell 仅支持 .NET Core 2.0。我已经向合适的工程师提出了这个问题,因此 Cloud Shell 图像已更新以支持 .NET Core 2.1。

同时:

  1. 根据这张图片创建一个 docker 文件: gcr.io/google-appengine/aspnetcore:2.1
  2. 尝试使用 gcloud builds submit to build an image. When you run gcloud builds submit for the first time, it will ask to enable Cloud Build API. Approve that. This will not use local (i. e. CloudShell's) docker build command but rather submit your artifacts to be built by Cloud Build 并推送到容器注册表。
  3. 使用 gcloud app deploy 部署到 AppEngine Flex,用图像地址指定 --image-url从您在上一步中构建的容器注册表中。