Azure DevOps – Unable to determine the location of vstest.console.exe easy fix

In Azure DevOps build pipeline, you may will use unit test task. If you got this error:

[error]System.Management.Automation.CmdletInvocationException: Unable to determine the location of vstest.console.exe ---> System.IO.FileNotFoundException: Unable to determine the location of vstest.console.exe 

means the build agent cannot find Visual Studio unit test tool folder. And this error probably will happen if you use a local private build agent.

The easiest way to fix this problem is copy your real unit test tool to the “target” folder build agent tried to find.

In theory, build agent tried to find vstest.console.exe in folder:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe

So check if your build agent server has this folder or not. If not, just create one and copy the unit test tool to this folder. The real unit test tool may in this folder if you use Visual Studio 2017:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow

(change Community to Enterprise or other if you use different version)

so copy all files and sub-folders in

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow

to folder:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow

Try to query a build again, and you will not have problem anymore.

Leave a comment