5

Locally my project builds fine with ng build --prod but if I set it up on tfs (team foundation server) with the following powershell script it fails with some errors.

ps script:

npm install
npm run ng build --prod

tfs build output:

  • [1m[33mWARNING in ./~/css-loader?{"sourceMap":false,"importLoaders":1}!./~/postcss-loader!./~/sass-loader!./src/scss/style.scss

  • autoprefixer: D:\a\1\s\src\scss\style.scss:7468:3: Replace transition-property to transition, because Autoprefixer could not support any cases of transition-property and other transition-* @ ./src/scss/style.scss 4:14-203 2017-04-30T07:17:51.9419669Z @ multi ./~/primeng/resources/themes/bootstrap/theme.css ./~/primeng/resources/primeng.min.css ./~/font-awesome/css/font-awesome.css ./src/scss/style.scss[39m[22m

  • [error] 0% compiling 10% building modules 0/1 modules 1 active multi D:\a\1\s\src\main.ts

  • [error]Process completed with exit code 0 and had 3 error(s) written to the error stream.

Rick
  • 1,224
  • 3
  • 13
  • 27
  • Try to remove local node_modules folder and run npm I and build again. Will you see the same error? – yurzui Apr 30 '17 at 09:24
  • Locally it builds fine but It does not build on team foundation server. – Rick Apr 30 '17 at 17:20
  • I see but maybe your packages versions are different with tfs. I had the same issue. It worked on locale machine because i used old version and didn't update local node_modules – yurzui Apr 30 '17 at 17:28
  • @yurzui I tried and it builds fine but not on tfs. Which build host do you use and is your script the same as mine? – Rick May 01 '17 at 18:44
  • I know that it could be run on your local server, could you please test it run this file or command manually on your build agent server. Your project is mapping down to the path `D:\a\1\s\`. – Tingting0929 May 02 '17 at 05:53
  • @Tingting0929-MSFT I'm sorry but how can I run it on my build agent? I'm using the hosted one on tfs. – Rick May 02 '17 at 19:03

3 Answers3

11

It works now, I removed the powershell script and added seperate tasks in the build process.

  • npm install (standard one)
  • npm install -g @angular/cli (command line)
  • ng build --prod (command line)

Update based on comment:

You can also use: npm run ng build -- --prod. This way you don't have to install angular/cli.

Rick
  • 1,224
  • 3
  • 13
  • 27
2

I was doing the same as the marked answer, but it bugged me that it's always installing angular-cli globally everytime. So i just switched that a bit like this:

node $(Build.SourcesDirectory)/node_modules/@angular/cli/bin/ng build --prod -op $(Build.BinariesDirectory) -v

now, after npm installs all the deps, it's gonna install cli too, and then just use that one.

Agash Thamo.
  • 748
  • 6
  • 18
2

Add npm Task (Add Task >> Package >> npm) with below configuration

enter image description here

ElasticCode
  • 7,311
  • 2
  • 34
  • 45