0

I am trying to build my angular solution using MsBuilds.

Following is my code snippet

>     <Exec Command="npm install" WorkingDirectory="$(SolutionRoot)\Dev\AngularUI" />
>     <Exec Command="npm install -g @angular/cli"  WorkingDirectory="$(SolutionRoot)\Dev\AngularUI" />
>     <Exec Command="ng build --prod" WorkingDirectory="$(SolutionRoot)\Dev\AngularUI" />

While the npm i command works fine , i get the error 'ng' is not recognized as an internal or external command on the ng build --prod command.

I try to run the same commands from cmd and it works fine from the same build account as well.

Deepanshu Kalra
  • 419
  • 2
  • 9
  • 23

1 Answers1

0

Try npm run ng build. The only issue with this is it omits any other parameter like --prod or --test after build.

Following are the commands what i am using to run my angular build successfully from Jenkins.Doing it the dirty way by setting up the path variables. Don't know if there is a cleaner way to do this. This does execute the commands properly without omitting anything.

set PATH=%PATH%;C:\Users\Administrator\AppData\Roaming\npm;C:\Users\Administrator\AppData\Roaming\npm\node_modules\@angular\cli\bin;

@echo on
cmd /c npm install -g @angular/cli@latest

echo yarn Install
cmd /c yarn

echo Build    
ng build --prod --aot=true

Probably you can remove cmd /c as well, will still work. Using it just in case of errors to handle stuff properly.

hakuna
  • 6,243
  • 10
  • 52
  • 77