Blazor Azure deployment error: "Error: Could not detect the language from repo."

Blazor Azure deployment error: "Error: Could not detect the language from repo."

我正在尝试将 Blazor .NET6 应用程序部署到 Azure 静态 Web 应用程序。 问题是当我设置它崩溃的构建时:

Error: Could not detect the language from repo.

我的部署配置:

name: Azure Static Web Apps CI/CD

on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches:
      - main

jobs:
  build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest
    name: Build and Deploy Job
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true
      - name: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GENTLE_MEADOW }}
          repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
          action: "upload"
          ###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
          # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
          app_location: "PortfolioWeb" # App source code path
          api_location: "" # Api source code path - optional
          output_location: "wwwroot" # Built app content directory - optional
          ###### End of Repository/Build Configurations ######

  close_pull_request_job:
    if: github.event_name == 'pull_request' && github.event.action == 'closed'
    runs-on: ubuntu-latest
    name: Close Pull Request Job
    steps:
      - name: Close Pull Request
        id: closepullrequest
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GENTLE_MEADOW_000314403 }}
          action: "close"

我的项目结构:

PortfolioWeb [repository]
├── .git
├── .github
├── PortfolioWeb [solution dir]
│   ├── .vs
│   ├── PortfolioWeb [project dir]
│   │   └── <blazor project files>
│   └── PortfolioWeb.sln
├── README.md
│   ├── default.html
│   └── post.html
└── .gitignore

我是不是把什么东西搞砸了?

app_location: "PortfolioWeb"
api_location: ""
output_location: "wwwroot"

在许多教程中,他们除了这个设置之外什么也没做。指定 src 文件夹和 wwwroot。那么为什么它在我的情况下也不起作用?

所以经过反复试验,我终于发现我必须从存储库中指定我的项目(而不是解决方案)的相对路径。所以当我在 PortfolioWebapp_location is:

app_location: "PortfolioWeb/PortfolioWeb"

换句话说

app_location: "<SolutionFolder>/<ProjectFolder>"

然后我的 Azure 静态 Web 应用程序成功部署并运行。