Intro
Today I would like to share with you how to fix following error occured while running Azure pipelines agent:
|
1 |
Unable to deploy to the target 'MACHINE-NAME' as some of the following demands are missing: [vstest, Agent.Version -gtVersion 2.115.0]. Ensure the target meets the specified demands and try again. |
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
- Download nuget package from https://www.nuget.org/packages/Microsoft.TestPlatform/
- Change the package extension from nupkg to zip(e.g. microsoft.testplatform.16.8.3.zip) and extract it.
- Open the extracted package and go to
.\microsoft.testplatform.16.8.3\tools\net451directory, there should be two directoriesCommon7andTeam Tools, copy them. - Open
C:\Program Filesand create directoryMicrosoft Test Platform - Paste
Common7andTeam Toolsfolders intoC:\Program Files\Microsoft Test Platform - Open Environment variables screen and add new System variable
VSTestwith valueC:\Program Files\Microsoft Test Platform\Common7\IDE\Extensions\TestPlatform.
Using PowerShell
Run following script in powershell as Administrator.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
$packageUrl = 'https://globalcdn.nuget.org/packages/microsoft.testplatform.16.8.3.nupkg' $scriptDir = "$env:TEMP\MSTestInstall" $packageFilePath = "$scriptDir\microsoft.testplatform.zip" $installationDirectory = "$Env:Programfiles\Microsoft Test Platform" New-Item $scriptDir -ItemType Directory -Force | Out-Null New-Item $installationDirectory -ItemType Directory -Force | Out-Null Start-BitsTransfer -Source $packageUrl -Destination $packageFilePath Expand-Archive -Path $packageFilePath -DestinationPath "$scriptDir\microsoft.testplatform" -Force Copy-Item -Path "$scriptDir\microsoft.testplatform\tools\net451\*" -Destination $installationDirectory -Recurse -Force [System.Environment]::SetEnvironmentVariable('VSTest', "$installationDirectory\Common7\IDE\Extensions\TestPlatform", [System.EnvironmentVariableTarget]::Machine) Write-Host "VSTest Console installed in $installationDirectory\Common7\IDE\Extensions\TestPlatform" Remove-Item $scriptDir -Recurse -Force |
Restarting Azure agent
Finally, open Services +R, type services.msc and hit Enter), find Azure pipelines Agent (…) service and restart it.
Verifying
In Azure DevOps go to your Agent, open tab Capabilities and you should see VSTest variable:
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.
In next post I’ll show how to address problems you might have running vstest.console.



