Azure DevOps管道 - Angular 13到Azure应用程序服务错误

发布于 2025-01-22 19:48:06 字数 835 浏览 2 评论 0原文

我正在尝试在Azure DevOps中为一个简单的Angular项目构建管道,但是我一直遇到一个错误“没有这样的文件或目录:D:/A/1/S/DIST”

这是我的YAML文件,

trigger:
- master

pool:
  vmImage: windows-latest

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'

    
- task: ArchiveFiles@2
  displayName: 'Archive files'
  inputs:
    rootFolderOrFile: '$(System.DefaultWorkingDirectory)/dist'
    includeRootFolder: false
    archiveType: zip
    archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
    replaceExistingArchive: true

- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
  artifact: drop

我缺少什么?这应该很简单,因为这只是一个小角度项目。看起来它无法构建和创建DIST文件夹。当我在本地手动进行时,它可以正常工作

I am trying to build a pipeline for a simple angular project in Azure Devops but I keep getting an error that "no such file or directory: D:/a/1/s/dist"

Here is my yaml file

trigger:
- master

pool:
  vmImage: windows-latest

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'

    
- task: ArchiveFiles@2
  displayName: 'Archive files'
  inputs:
    rootFolderOrFile: '$(System.DefaultWorkingDirectory)/dist'
    includeRootFolder: false
    archiveType: zip
    archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
    replaceExistingArchive: true

- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
  artifact: drop

What am I missing? This should be faily simple as this is just a small angular project. It looks like it is not able to build and create dist folder. When I do it manually locally it works fine

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

熊抱啵儿 2025-01-29 19:48:06

这是由于“ DIST”并未在文件夹$(System.DefaultWorkingDirectory)下创建。实际上并未成功执行ng build -prod

请将任务分为三个:

- script: |
    npm install -g @angular/cli
  displayName: 'npm install and build'

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

- script: |
    ng build --prod --verbose
  displayName: 'npm install and build'

或在NPM命令之间添加&

- script: |
    npm install -g @angular/cli && npm install && ng build --prod --verbose
  displayName: 'npm install and build'

我与您有相同的问题,并通过分离的任务解决。通过分开的任务,它将确保执行每个步骤。

This is due to the 'dist' is not created under the folder $(System.DefaultWorkingDirectory). The ng build --prod was not successfully executed actually.

Please split the task into 3 ones:

- script: |
    npm install -g @angular/cli
  displayName: 'npm install and build'

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

- script: |
    ng build --prod --verbose
  displayName: 'npm install and build'

Or add && between the npm command:

- script: |
    npm install -g @angular/cli && npm install && ng build --prod --verbose
  displayName: 'npm install and build'

I have the same issue with you and resolved with separated tasks. with seperated task, it will make sure each step is executed.

enter image description here

亣腦蒛氧 2025-01-29 19:48:06

您可以尝试使用 WorkingDir 属性。这是管道的提取物
我用来发布角度图书馆文物。我也有类似的问题,发现此答案。这是我正在使用的管道的摘录:

- task: Npm@1
  inputs:
    command: 'publish'
    workingDir: 'dist/command-queue'
    publishRegistry: 'useFeed'
    publishFeed: '[my artifacts feed goes here]'
  displayName: 'npm push'

You can try to use workingDir property. This is an extract of a pipeline
I am using to publish an angular library artifact. I had a similar problem and found this answer. This is an extract of the pipeline I am using:

- task: Npm@1
  inputs:
    command: 'publish'
    workingDir: 'dist/command-queue'
    publishRegistry: 'useFeed'
    publishFeed: '[my artifacts feed goes here]'
  displayName: 'npm push'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文