2

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.

The build command requires to be run in an Angular project, but a project definition could not be found.

Can someone help me please.

Powershell script:

npm install

npm install -g typescript

npm install -g @angular/cli

ng build --configuration=production

This is all the result of powershell script:

##[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
+ [email protected]
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: [email protected] (node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ @angular/[email protected]
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
4
  • before the ng build add cd path/to/angular/project Commented May 22, 2019 at 9:04
  • Can you please confirm that your repository is getting cloned during build process ? A common build logs of angular cli project : 1) Prepare job 2) Initialize job 3) Checkout 4) Use Node 10.15.3 5) npm install packages 6) npm build Commented May 22, 2019 at 9:13
  • The problem was file path of Angular project like Shayki Abramczyk said, who comments to my question. When I push my branch to Azure Devops, They create a directory with the name of the project but I thought that Powershell script would work in angular project, however I was wrong. Thanks. Commented May 22, 2019 at 10:00
  • @sapfile Great! I also added it as answer :) Commented May 22, 2019 at 10:25

1 Answer 1

2

As the error said, you try to run ng build not in the project folder.

You need to run cd path/to/project-folder before.

Another option, in the Azure DevOps PowerShell task there is a option to specify "Working Directory" so enter there the project path.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.