Intro

Today I would like to share with you how to fix following error occured while running Azure pipelines agent:

I was obviously trying to run some test on that machine using VSTest task, but vstest.console.exe nor Visual Studio was installed there.

Fixing

To fix our problem we need to somehow get vstest.console.exe on our machine. We can do that either by installing Visual Studio or by using Microsoft.TestPlatform nuget package. I will show you the second method and I even prepared powershell script if you want.

Manually

  1. Download nuget package from https://www.nuget.org/packages/Microsoft.TestPlatform/
  2. Change the package extension from nupkg to zip(e.g. microsoft.testplatform.16.8.3.zip) and extract it.
  3. Open the extracted package and go to .\microsoft.testplatform.16.8.3\tools\net451 directory, there should be two directories Common7 and Team Tools, copy them.
  4. Open C:\Program Files and create directory Microsoft Test Platform
  5. Paste Common7 and Team Tools folders into C:\Program Files\Microsoft Test Platform
  6. Open Environment variables screen and add new System variable VSTest with value C:\Program Files\Microsoft Test Platform\Common7\IDE\Extensions\TestPlatform.

System

Using PowerShell

Run following script in powershell as Administrator.

Restarting Azure agent

Finally, open Services +R, type services.msc and hit Enter), find Azure pipelines Agent (…) service and restart it.

Azure

Verifying

In Azure DevOps go to your Agent, open tab Capabilities and you should see VSTest variable:

Azure

Finalizing

This should fix the problem with missing vstest capability. One more thing you might have to do is to open your pipeline definition and under VsTest task change Path to vstest.console.exe field to: C:\Program Files\Microsoft Test Platform\Common7\IDE\Extensions\TestPlatform\vstest.console.exe.

VsTest

In next post I’ll show how to address problems you might have running vstest.console.

Last modified: February 8, 2022
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments