简体   繁体   English

使用Powershell脚本在Azure DevOps上进行角度生成错误

[英]Angular build error on Azure DevOps with powershell script

I prepared a powershell script in azure devops build pipeline to create an artifact, but when I start build queue, I get an error which is below. 我在azure devops构建管道中准备了一个powershell脚本来创建工件,但是当我开始构建队列时,出现以下错误。

The build command requires to be run in an Angular project, but a project definition could not be found. build命令需要在Angular项目中运行,但是找不到项目定义。

Can someone help me please. 有人能帮助我吗。

Powershell script: Powershell脚本:

npm install

npm install -g typescript

npm install -g @angular/cli

ng build --configuration=production

This is all the result of powershell script: 这是powershell脚本的全部结果:

##[section]Starting: PowerShell Script
==============================================================================
Task         : PowerShell
Description  : Run a PowerShell script on Windows, macOS, or Linux.
Version      : 2.148.0
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613736)
==============================================================================
Generating script.
========================== Starting Command Output ===========================
##[command]"C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'd:\a\_temp\90129c3e-4840-41d7-895c-2f9c8f6e5968.ps1'"
npm WARN saveError ENOENT: no such file or directory, open 'D:\a\1\s\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'D:\a\1\s\package.json'
npm WARN s No description
npm WARN s No repository field.
npm WARN s No README data
npm WARN s No license field.

up to date in 5.231s
found 0 vulnerabilities

C:\npm\prefix\tsc -> C:\npm\prefix\node_modules\typescript\bin\tsc
C:\npm\prefix\tsserver -> C:\npm\prefix\node_modules\typescript\bin\tsserver
+ typescript@3.4.5
updated 1 package in 2.063s
C:\npm\prefix\ng -> C:\npm\prefix\node_modules\@angular\cli\bin\ng
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ @angular/cli@7.3.9
added 295 packages from 180 contributors in 88.373s
The build command requires to be run in an Angular project, but a project definition could not be found.
##[error]PowerShell exited with code '1'.
##[section]Finishing: PowerShell Script

As the error said, you try to run ng build not in the project folder. 如错误所述,您尝试不在项目文件夹中运行ng build

You need to run cd path/to/project-folder before. 您需要先运行cd path/to/project-folder

Another option, in the Azure DevOps PowerShell task there is a option to specify "Working Directory" so enter there the project path. 另一个选项是,在Azure DevOps PowerShell任务中,有一个选项可以指定“工作目录”,因此请在其中输入项目路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Powershell触发Azure DevOps中的构建 - Powershell to trigger a build in Azure DevOps 如何将 Powershell 脚本文件路径从 azure devops repo 传递到 Azure devops 构建管道 - how to pass Powershell script filepath from azure devops repo into Azure devops build pipeline Azure devOps管道中的Powershell脚本 - Powershell script in azure devOps pipeline Azure DevOps 任务内联脚本与 powershell 不会因错误而导致任务失败 - Azure DevOps task inline script with powershell does not fails the task on error Azure DevOps:如何从 Release Pipeline 中的 PowerShell 脚本构建 Azure Pipeline 检索构建工件? - Azure DevOps: How to retrieve a build artifact from build Azure Pipeline from a PowerShell Script in Release Pipeline? 如何在Azure DevOps构建期间使用PowerShell脚本将构建工件推送到Git存储库? - How to push build artifacts to Git repository using PowerShell script during Azure DevOps build? 用户 PowerShell 在 Azure Devops 中排队构建 - User PowerShell to Queue a Build in Azure Devops Azure devops - 更新 json 文件 - powershell 脚本 - Azure devops - update json file - powershell script PowerShell任务脚本路径Azure DevOps发布 - Script path of PowerShell task Azure DevOps release 通过 Powershell 脚本在 Azure Devops 中创建 fork 存储库 - Create fork repository in Azure Devops by Powershell script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM