我正在努力获得一个简单的构建和部署工作,并希望得到一些帮助。有人能回顾一下这些步骤,以及为什么发布工件不起作用吗?这是一个简单的Angular 7项目。
错误:
[section]Starting:Publish Artifact:dist = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =任务:发布构建构件描述:将构建构件发布到Azure Pipelines/TFS或文件共享版本:1.142.2作者:微软公司帮助:更多信息
[警告]目录“D:\a\1\s\dist”为空。不会向生成项目“dist”添加任何内容。[section]完成:发布工件:dist
YAML:
pool:
vmImage: Hosted VS2017
demands: npm
steps:
- script: |
echo Write your commands here
mkdir dist
echo Use the environment variables input below to pass secret variables to this script
displayName: 'Command - mkdir dist'
- task: Npm@1
displayName: 'npm install'
inputs:
verbose: false
- task: Npm@1
displayName: 'npm build'
inputs:
command: custom
verbose: false
customCommand: 'build --prod'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: dist'
inputs:
PathtoPublish: dist
ArtifactName: dist
- task: FtpUpload@1
displayName: 'FTP Upload: dist'
inputs:
credentialsOption: inputs
serverUrl: ‘xxx’
username: Tester2
password: 'Tester$2'
rootDirectory: dist
filePatterns: '*'
remoteDirectory: /
trustSSL: true
Azure DevOps Pipeline issue
“发布构建工件”任务用于将构建工件发布到Azure Pipelines、TFS或文件共享。
但是,正如Daniel和Andrey所说,虽然您添加了< code>npm build,但是您没有将安装的文件夹设置为< code>dist。因此< code>npm build的结果不会保存在dist文件夹中。在这种情况下,文件夹< code>dist为空。
此外,要将构建结果保存到dist文件夹,您可以尝试使用选项--op
,如下所示:
run ng build --prod -- -op ..\..\dist
<代码>..\..\dist应使用基于< code>project.html" target="_blank">json文件的相对路径。
查看文档JavaScript框架:AngularJS以了解更多详细信息。
希望这有所帮助。