Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Google Cloud Shell "gcloud run deploy" Error

I have one application on "Cloud Run".
When i compile this application using "Cloud Build", there is no problem.
I'm getting the following error when I want to "deploy" using "gcloud" commands with "Google Cloud SDK Shell" on my local machine. Example: "gcloud run deploy cloudruntestdocker --source . --region europe-west4 --project divine-axis-328214 --verbosity=debug"

Error Log
----------------------------------------------------------------
[builder] Welcome to .NET Core 3.1!
[builder] ---------------------
[builder] SDK Version: 3.1.414
[builder]
[builder] ----------------
[builder] Explore documentation: https://aka.ms/dotnet-docs
[builder] Report issues and find source on GitHub: https://github.com/dotnet/core
[builder] Find out what's new: https://aka.ms/dotnet-whats-new
[builder] Learn about the installed HTTPS developer cert: https://aka.ms/aspnet-core-https
[builder] Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
[builder] Write your first app: https://aka.ms/first-net-core-app
[builder] ----------------------------------------------- ---------------------------------------
[builder] Determining projects to restore...
[builder] Restored /workspace/GoogleCloudTest/GoogleCloudTest.csproj (in 6.72 sec).
[builder] Done "dotnet restore --packages /layers/google.dotnet.publish/pack..." (8.237855964s)
[builder] ----------------------------------------------- ---------------------------------
[builder] Running "dotnet publish -nologo --verbosity minimal --configuration Release --output bin --no-restore --packages /layers/google.dotnet.publish/packages ./GoogleCloudTest/GoogleCloudTest.csproj (DOTNET_CLI_TELEMETRY_OPTOUT=true )"
[builder] /layers/google.dotnet.runtime/sdk/3.1.414/Microsoft.Common.CurrentVersion.targets(1177.5): error MSB3971: The reference assemblies for ".NETFramework,Version=v5.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK. [/workspace/GoogleCloudTest/GoogleCloudTest.csproj]
[builder] Done "dotnet publish -nologo --verbosity minimal --configuration R..." (970.146624ms)
[builder] Failure: (ID: bd11cdaa) /layers/google.dotnet.runtime/sdk/3.1.414/Microsoft.Common.CurrentVersion.targets(1177.5): error MSB3971: The reference assemblies for ".NETFramework,Version =v5.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK. [/workspace/GoogleCloudTest/GoogleCloudTest.csproj]
[builder] ----------------------------------------------- ---------------------------------
[builder] Sorry your project couldn't be built.
[builder] Our documentation explains ways to configure Buildpacks to better recognize your project:
[builder] -> https://github.com/GoogleCloudPlatform/buildpacks/blob/main/README.md
[builder] If you think you've found an issue, please report it:
[builder] -> https://github.com/GoogleCloudPlatform/buildpacks/issues/new
[builder] ----------------------------------------------- ---------------------------------
[builder] ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle. This may be the result of using an untrusted builder: failed with status code: 51
ERROR
ERROR: build step 0 "gcr.io/k8s-skaffold/pack" failed: step exited with non-zero status: 1
----------------------------------------------------------------

The dotnet version shows as ".NET Core 3.1". But my version is ".NET5".
I'm pretty sure the cause of the error is related to that.
And it uses "gcr.io/k8s-skaffold/pack" as "buildpacks".
However, I am using "cloudbuild.yaml" as my buildpacks and I cannot set it.

When I do the Cloud Build process on the website,
it compiles without any problems because I use the configuration "Cloud Build configuration file (yaml or json)" and "cloudbuild.yaml".

Below you can find the contents of this file.

cloudbuild.yaml
----------------------------------------------------------------
steps:
- name: gcr.io/cloud-builders/docker
args:
- build
- '-t'
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
- $_DOCKER_FOLDER
id: Dockerfile
- name: gcr.io/cloud-builders/docker
args:
- push
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
id: push
- name: gcr.io/cloud-builders/gcloud
args:
- run
- deploy
- $_SERVICE_NAME
- '--platform=$_PLATFORM'
- '--image=$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
- '--region=$_DEPLOY_REGION'
id: Deploy
images:
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
options:
substitutionOption: ALLOW_LOOSE
substitutions:
_GCR_HOSTNAME: eu.gcr.io
_PLATFORM: managed
_SERVICE_NAME: cloudruntestdocker
_DEPLOY_REGION: europe-west4
_DOCKER_FOLDER: GoogleCloudTest
tags:
- gcp-cloud-build-deploy-cloud-run
- gcp-cloud-build-deploy-cloud-run-managed
- cloudruntestdocker
----------------------------------------------------------------

How can I deploy with "Google Cloud SDK Shell" and "cloudbuild.yaml" file on my local machine.

0 1 6,910
1 REPLY 1