Today I would like to share with you how to fix following error occured while running Azure pipelines agent:
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.
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.
- 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 directories
Team Tools, copy them.
C:\Program Filesand create directory
Microsoft Test Platform
Team Toolsfolders into
C:\Program Files\Microsoft Test Platform
- Open Environment variables screen and add new System variable
C:\Program Files\Microsoft Test Platform\Common7\IDE\Extensions\TestPlatform.
Run following script in powershell as Administrator.
$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.
In Azure DevOps go to your Agent, open tab
Capabilities and you should see
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.