部署.NET 6 Web API至App Engine Flex时Cloud Build失败求助
我正在基于Google Cloud探索.NET Core项目,尝试将.NET 6 Web API应用发布至App Engine Flex。我的解决方案包含1个Web API项目及4个被其引用的类库项目。已在GCP创建项目、启用所需API,并在本地配置好Google Cloud CLI。
第一次部署尝试及错误
从Web API项目目录执行以下命令启动部署:
gcloud app deploy
构建失败,错误信息为“Reference Project Not Found”:
Step #2 - "build": Skipping project "/csproj" because it was not found.
Step #2 - "build": Skipping project "/.csproj" because it was not found.
Step #2 - "build": Skipping project "/.csproj" because it was not found.
Step #2 - "build": Skipping project "/.csproj" because it was not found.
Step #2 - "build": Skipping project "/csproj" because it was not found.
Step #2 - "build": Skipping project "/.csproj" because it was not found.
Step #2 - "build": Skipping project "/.csproj" because it was not found.
Step #2 - "build": Restored /workspace/.csproj (in 189 ms).
Step #2 - "build": Done "dotnet restore --packages /layers/google.dotnet.publish/pack..." (2.797299621s)
Step #2 - "build": WARNING: A project file was uploaded, causingdotnet publishto be called, but the output bin folder already existed in application source. Deleting /layers/google.dotnet.publish/publish/bin.
Step #2 - "build": --------------------------------------------------------------------------------
Step #2 - "build": Running "dotnet publish -nologo --verbosity minimal --configuration Release --output /layers/google.dotnet.publish/publish/bin --no-restore --packages /layers/google.dotnet.publish/packages ./.csproj (DOTNET_CLI_TELEMETRY_OPTOUT=true)"
Step #2 - "build": /layers/google.dotnet.sdk/sdk/sdk/6.0.411/Microsoft.Common.CurrentVersion.targets(2066,5): warning : The referenced project '../.csproj' does not exist. [/workspace/******.csproj]
第二次部署尝试及错误
将app.yaml文件从Web API项目目录移至解决方案目录,并从该目录执行部署命令,但此次构建仍失败,错误信息为“expected to find exactly one project file in directory”:
Step #2 - "build": Warning: BOM table is deprecated in this buildpack api version, though it remains supported for backwards compatibility. Buildpack authors should write BOM information to
.sbom. , launch.sbom. , or build.sbom. .
Step #2 - "build": === .NET - Publish (google.dotnet.publish@0.9.0) ===
Step #2 - "build": --------------------------------------------------------------------------------
Step #2 - "build": Running "find . -regex .\.\(cs\|fs\|vb\)proj"
Step #2 - "build": ./.csproj
Step #2 - "build": ./.csproj
Step #2 - "build": ./.csproj
Step #2 - "build": ./.csproj
Step #2 - "build": ./.csproj
Step #2 - "build": Done "find . -regex .\.\(cs\|fs\|vb\)proj" (5.549085ms)
Step #2 - "build": Failure: (ID: 46b43786) expected to find exactly one project file in directory ., found [./.csproj ./.csproj ./.csproj ./.csproj ./**.csproj]
Step #2 - "build": --------------------------------------------------------------------------------
Step #2 - "build": Running "mv -f /builder/outputs/output-6447353496926691534 /builder/outputs/output"
Step #2 - "build": Done "mv -f /builder/outputs/output-6447353496926691534 /builder/o..." (8.697702ms)
Step #2 - "build": ERROR: failed to build: exit status 1
Finished Step #2 - "build"
ERROR
ERROR: build step 2 "us.gcr.io/gae-runtimes/buildpacks/google-gae-22/dotnet/builder:dotnet_20230703_RC00" failed: step exited with non-zero status: 51
附:app.yaml文件内容
runtime: aspnetcore env: flex runtime_config: operating_system: ubuntu22 # 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/dotnet/configuring-your-app-with-app-yaml manual_scaling: instances: 1 resources: cpu: 1 memory_gb: 0.5 disk_size_gb: 10
内容的提问来源于stack exchange,提问作者Gaurav

