Azure DevOps管道 - Angular 13到Azure应用程序服务错误
我正在尝试在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是由于“ DIST”并未在文件夹
$(System.DefaultWorkingDirectory)
下创建。实际上并未成功执行ng build -prod
。请将任务分为三个:
或在NPM命令之间添加
&
:我与您有相同的问题,并通过分离的任务解决。通过分开的任务,它将确保执行每个步骤。
This is due to the 'dist' is not created under the folder
$(System.DefaultWorkingDirectory)
. Theng build --prod
was not successfully executed actually.Please split the task into 3 ones:
Or add
&&
between the npm command:I have the same issue with you and resolved with separated tasks. with seperated task, it will make sure each step is executed.
您可以尝试使用 WorkingDir 属性。这是管道的提取物
我用来发布角度图书馆文物。我也有类似的问题,发现此答案。这是我正在使用的管道的摘录:
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: