为什么 azure 构建管道不为 Angular 构建生成 dist 文件夹

2co*_*ool 6 azure-devops azure-pipelines azure-yaml-pipelines

在我运行任何其他任务 dist 文件夹之前,构建过程中生成的文件夹似乎已被删除。

 trigger:
    - master
    
    pool: default
    
    steps:
    - task: NodeTool@0
      inputs:
        versionSpec: '10.x'
      displayName: 'Install Node.js'
    
    - script: |
        npm install -g @angular/cli
        npm install
        ng build --prod 
      displayName: 'npm install and build'
    
    #i added this task and it seems like the node_modules and the dist 
    #folder that was generated during the build are not getting copied to the (a)directory 
    #only the source code get copied. it seems like the folders are getting
    #deleted even before the #PublishPipelineArtifact@1 task ran
    
    - task: PublishPipelineArtifact@1
      inputs:
        targetPath: '$(Pipeline.Workspace)/s'
        publishLocation: 'pipeline'
Run Code Online (Sandbox Code Playgroud)

我还尝试在中输出构建

Wes*_*ika 3

首先将npm install脚本与ng build脚本分开。其次,我是在跑步npm build 而不是 ng build。我花了几个小时才注意到。这解决了我的 dist 文件夹未创建的问题。

- script: |
    npm install
  displayName: 'npm install'

- script: |
    ng build --prod
  displayName: 'ng build'
Run Code Online (Sandbox Code Playgroud)