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

Azure DevOps部署Angular至静态Web应用报错:找不到默认文件

问题排查与修复

错误原因分析

错误提示Failed to find a default file in the app artifacts folder (/). Valid default files: index.html,Index.html,核心是部署任务配置的路径和实际构建产物的存放路径不匹配,同时存在无效的目录操作步骤。

具体问题点

  1. 无效的bash cd步骤:每个bash步骤都是独立的Shell环境,前一步的目录切换不会影响后续任务的工作目录,这两步完全起不到作用,还会干扰路径判断。
  2. 路径配置错误:
    • cwd设为$(Pipeline.Workspace)、app_location设为/后,任务会在$(Pipeline.Workspace)/目录下查找output_location指定的dist/po-master-frontend,但实际构建产物存放在$(Pipeline.Workspace)/app/dist/po-master-frontend(因为下载的artifact名为app,默认会放在$(Pipeline.Workspace)/app目录下)。

修复后的YAML配置

# Deploy pipeline
trigger: none
stages:
 - stage: Deploy
   pool:
     vmImage: 'ubuntu-latest'
   jobs:
    - job: DeployFrontEnd
      steps:
       - task: DownloadPipelineArtifact@2
         inputs:
           buildType: 'specific'
           project: 'POMaster'
           definition: 'frontend'
           buildVersionToDownload: 'latest'
           allowPartiallySucceededBuilds: true
           allowFailedBuilds: true
           artifactName: 'app'
           targetPath: '$(Pipeline.Workspace)'
       - task: AzureStaticWebApp@0
         inputs:
           app_location: '$(Pipeline.Workspace)/app'
           skip_app_build: true
           skip_api_build: true
           verbose: true
           output_location: 'dist/po-master-frontend'
         env:
           azure_static_web_apps_api_token: '$(deployment_token)'

额外验证建议

  • 若构建流水线是直接将dist/po-master-frontend下的文件(而非整个dist目录)作为app artifact上传,需删除output_location配置,仅保留app_location: '$(Pipeline.Workspace)/app'即可,此时index.html直接在该目录下。
  • 可在部署任务前添加以下步骤确认文件结构,排查路径问题:
    ls -la $(Pipeline.Workspace)/app
    

内容的提问来源于stack exchange,提问作者shah harshil

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.25 07:31:13