Blazor Azure 部署错误:“错误:无法从存储库检测到语言。”

问题描述 投票:0回答:1

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

错误:无法从存储库中检测到语言。

我的部署配置:

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 之外什么也没做。那么为什么它在我的情况下不起作用呢?

azure blazor .net-6.0 azure-static-web-app
1个回答
4
投票

我发现我必须从存储库指定我的项目(而不是解决方案)的相对路径。所以当我在

PortfolioWeb
app_location is
:

app_location: "PortfolioWeb/PortfolioWeb"

换句话说

app_location: "<SolutionFolder>/<ProjectFolder>"

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

文档: https://learn.microsoft.com/sl-si/azure/static-web-apps/build-configuration?WT.mc_id=DOP-MVP-4020672&tabs=github-actions

© www.soinside.com 2019 - 2024. All rights reserved.