You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GCP部署.NET Core 3.1云函数失败求助:runtimeconfig.json不存在错误排查

Troubleshooting "runtimeconfig.json does not exist" Error for .NET Core 3.1 Cloud Function Deployment

Let's break down why you're hitting this error—even with the previously working package—and walk through actionable fixes:

Possible Causes & Step-by-Step Fixes

1. Your Deployment Package Is Missing Proper Build Output (or Packed Incorrectly)

This is the most common culprit. When you first deployed successfully, you likely packaged the published build output (from dotnet publish) instead of raw source code. Now, if you're zipping up unbuilt source files without ensuring GCP can generate the runtimeconfig.json during build, it'll fail to find the file.

  • Fix Steps:
    • Navigate to your my-function directory locally.
    • Run the publish command to generate production-ready build files:
      dotnet publish -c Release -o ./publish
      
    • Zip up the contents of the publish directory (not the directory itself) and use this zip for deployment.
    • If you prefer deploying source code directly:
      • Ensure your zip includes the entire src directory (both my-function and referenced_solution folders) so GCP can build all dependent projects.
      • Double-check that your GOOGLE_BUILDABLE="./my-function" config points directly to the folder containing your my-function.csproj file.

2. GCP Build Cache Is Stuck in a Corrupted State

Even when using your old working package, GCP might be reusing stale build cache from your failed deployment attempts. This cache can persist and prevent the build from generating required files correctly.

  • Fix:
    • Add the --no-cache flag to your deployment command to force a fresh, clean build:
      gcloud functions deploy YOUR_FUNCTION_NAME --runtime dotnet31 --trigger-http --no-cache --set-build-env-vars GOOGLE_BUILDABLE="./my-function"
      

3. Dependent Projects in referenced_solution Aren't Being Built Correctly

Your multi-project setup requires GCP to build all referenced projects before compiling my-function. If project references are misconfigured or dependent folders are missing from your zip, the build will fail, and runtimeconfig.json won't be generated.

  • Fix Steps:
    • Open your my-function.csproj and verify project references point to the correct paths. For example:
      <ItemGroup>
        <ProjectReference Include="../referenced_solution/project1/project1.csproj" />
        <ProjectReference Include="../referenced_solution/project2/project2.csproj" />
      </ItemGroup>
      
    • Test a local build first: Run dotnet build from the root of your src directory to confirm all projects compile successfully, then check that runtimeconfig.json exists in my-function/bin/Release/netcoreapp3.1/.
    • Never exclude the referenced_solution folder from your deployment zip—GCP needs those projects to build your function.

4. runtimeconfig.json Generation Is Disabled in Your Project

Rarely, a custom project setting might turn off the automatic generation of this file.

  • Fix:
    • Open my-function.csproj and look for this property:
      <GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles>
      
    • If present, change the value to true or remove the line entirely (the default behavior is to generate the file).

Quick Test Order to Save Time

Try these steps in this priority:

  1. Deploy with --no-cache first to rule out cache issues.
  2. Verify your local build generates runtimeconfig.json correctly.
  3. Check that your deployment package includes all necessary source files or proper publish output.

内容的提问来源于stack exchange,提问作者adam.k

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.27 18:12:40