TFS 2015 Agent Versions Matter

If you follow my tweets you, probably know I’m a big fan of the new build/release system in TFS 2015 and VSTS.  It is super flexible and supports so many new use cases.  We upgraded from TFS 2010 to 2015 last year and have been using the build system successfully since.

We typically have 4 agents in our default pool all configured to run in interactive mode based on Donovan’s instructions so we can run our CodedUI and Selenium tests.  Last week however one of the agents started failing any build with the following error or something very similar:

Set workingFolder to default: c:\Program Files\Agent\tasks\CmdLine\1.0.12
module.js:338
    throw err;
    ^
Error: Cannot find module 'vso-task-lib'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:286:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (c:\Program Files\Agent\tasks\CmdLine\1.0.12\cmdLine2.js:2:10)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:475:10)

The new build system uses tasks to perform build and release actions.  There are two types of tasks: cross-platform tasks developed with Node.js and Windows only tasks developed in PowerShell.  Most of the open source tasks developed by Microsoft are written in Node.js so they run on Linux and macOS in addition to Windows.  You can see in the error above that version 1.0.12 of the CmdLine task failed with the error “Cannot find module ‘vso-task-lib’”.  This is an NPM module that can’t be found.

If you look at the version of the CmdLine task on GitHub, you will see the latest version is 1.0.27.  So my first thought was I needed to update the task.  But that doesn’t make sense because this is a task the comes in the box with TFS so you update the tasks by updating TFS and I knew we hadn’t installed any updates.

Next I thought I needed to install the vso-task-lib NPM module and while that may have fixed the issue it didn’t explain why it stopped working all of the sudden.  So that wasn’t good enough. 

The Cause

Finally, I noticed an agent.old folder on the agent filesystem and that the new agent folder had a creation date that matched the date everything stopped working.  BINGO!

image

But why?   Apparently “someone” reinstalled the agent with the wrong version.  I’m not sure where they got it but it wasn’t right.

The Solution

All you need to do is reinstall the right version of the agent.  Luckily, the VSTS team conveniently placed a “Download agent” link to the appropriate agent version for your version of TFS on the Control panel  – Agent pools  page. 

image

 

Please leave a comment if this posts helps you fix a similar issue or if you have further questions.

Please follow and like us:

Leave a Reply