Search code examples
asp.net-core.net-coregoogle-cloud-platformgoogle-cloud-shell

Building .NET Core 2.1 app fails in Google Cloud Shell


I've created an ASP.NET Core 2.1 app that I'm trying to deploy to Google Cloud Platform. It builds just fine using dotnet build locally.

I cannot build it through Google Cloud Shell, though. Running dotnet --version confirms the Google Cloud Shell has .NET Core 2.0 installed.

Running gcloud app deploy initiates a deployment of the app, but I receive a cryptic error from the log saying:

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

I was under the impression that GCP supports .NET Core 2.1 containers by default, so I haven't included a Dockerfile.

I'm trying to deploy to the flexible environment, here's my app.yaml file:

runtime: aspnetcore
env: flex

Do I need to create a custom Docker container? Or is there some other way to get support for .NET Core 2.1 in Google Cloud Shell?

Edit: For now I've installed Google Cloud Tools to run gcloud app deploy in a shell locally after running dotnet publish.


Solution

  • I tried to reproduce it - indeed, Cloud Shell supports .NET Core 2.0 only. I've raised that with the right engineers so Cloud Shell image is updated to support .NET Core 2.1.

    In the meantime:

    1. Create a docker file based off of this image: gcr.io/google-appengine/aspnetcore:2.1
    2. Try using 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 and pushed to container registry.
    3. Deploy to AppEngine Flex with gcloud app deploy, specifying --image-url with the image address from container registry as you built it in previous step.