Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure DevOps上带powershell脚本的角度构建错误_Powershell_Azure Devops_Angular7_Azure Pipelines - Fatal编程技术网

Azure DevOps上带powershell脚本的角度构建错误

Azure DevOps上带powershell脚本的角度构建错误,powershell,azure-devops,angular7,azure-pipelines,Powershell,Azure Devops,Angular7,Azure Pipelines,我在azure devops构建管道中准备了一个powershell脚本来创建工件,但是当我启动构建队列时,我得到一个错误,如下所示 build命令需要在角度项目中运行,但是 找不到项目定义 谁能帮帮我吗 Powershell脚本: npm install npm install -g typescript npm install -g @angular/cli ng build --configuration=production ##[section]Starting: PowerS

我在azure devops构建管道中准备了一个powershell脚本来创建工件,但是当我启动构建队列时,我得到一个错误,如下所示

build命令需要在角度项目中运行,但是 找不到项目定义

谁能帮帮我吗

Powershell脚本:

npm install

npm install -g typescript

npm install -g @angular/cli

ng build --configuration=production
##[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
这是powershell脚本的全部结果:

npm install

npm install -g typescript

npm install -g @angular/cli

ng build --configuration=production
##[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

正如错误所说,您试图运行
ng build
而不是在项目文件夹中

您需要先运行
cd path/to/project文件夹


另一个选项,在Azure DevOps PowerShell任务中有一个指定“工作目录”的选项,因此在那里输入项目路径。

ng构建之前
添加
cd路径/to/angular/project
您能否确认您的存储库在构建过程中被克隆?angular cli项目的常见构建日志:1)准备作业2)初始化作业3)签出4)使用节点10.15.3 5)npm安装包6)npm构建问题是angular项目的文件路径,如Shayki Abramczyk所说,他对我的问题发表了评论。当我将我的分支推到Azure Devops时,他们创建了一个带有项目名称的目录,但我认为Powershell脚本可以在angular项目中工作,但我错了。谢谢,太好了!我还添加了它作为答案:)