Skip to content

Script task does not run tests on Windows agents #10

@mikeharder

Description

@mikeharder

This script task does not run tests on Windows agents:

- script: |
npm install
npm test

To repro, change the vmImage to vs2017-win2016 and trigger a build.

I believe this happens because:

  • npm is npm.cmd on Windows
  • The script task combines npm install and npm test into a single .cmd file and executes it
  • When an outer batch file calls an inner batch file (without using call syntax), when the inner batch file returns, the outer batch file exits early
  • So, the generated .cmd file exits after the first npm command

You can repo this on any Windows machine by executing a batch file containing:

npm install
npm test

To execute both commands, the call syntax must be used:

call npm install
call npm test

I believe the best fix is to use the Npm task instead of the script task (#3).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions