Why does TFS agent doesn't discover a VSTEST capability - tfs

We have TFS 2015 server and also a build server with Visual Studio 2017 Ultimate. TFS agent is not able to detect VisualStudio or VsTest capabilities (as it should) but when added manually, there is still a problem.
When it comes to Visual Studio Test step then console shows the following error and fails:
c:\AgentTest\tasks\VSTest\1.0.30\VSTest.ps1
Unable to determine the location of vstest.console.exe
I added the following capabilities manually:
VisualStudio C:\Program Files (x86)\Microsoft Visual
Studio\2017\Enterprise VisualStudio_15.0 C:\Program Files
(x86)\Microsoft Visual Studio\2017\Enterprise
VisualStudio_IDE C:\Program Files (x86)\Microsoft Visual
Studio\2017\Enterprise\Common7\IDE
VisualStudio_IDE_15.0 C:\Program
Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE
VS150COMNTOOLS C:\Program Files (x86)\Microsoft Visual
Studio\2017\Enterprise\Common7\Tools\
VSTest C:\Program Files
(x86)\Microsoft Visual
Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow
VSTest_15.0 C:\Program Files (x86)\Microsoft Visual
Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow
This is my Visual Studio Test settings:

I can reproduce this issue, TFS 2015 agent cannot identify VStest and some other 2017 related capabilities.
Based on the test, TFS 2015 should not support for 2017 VStest.
According to this Github discussion, it seems that the core issue is the Visual Studio Test task needs updated to support VS 2017.
In TFS 2017 and VSTS, we can specify the absolute path of the vstest.console.exe to let it work (See this article for details), but in TFS 2015 we can not specify the path in the task, it's not support.
So, if you want to use Vstest, you can install VS 2015, or upgrade to TFS 2017 or later version.
Similar thread for your reference: https://social.msdn.microsoft.com/Forums/vstudio/en-US/1f9992f3-20b6-437a-855d-ccd67ff2298e/using-tfs-2015-with-build-agent-and-visual-studio-2017?forum=tfsadmin

Related

Location of nmake in VS2019 is not generic. Or am I missing something?

I am creating a generic script to deploy on the build server to build our project using VS 2019. The location of nmake in VS 2019 is at: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin. The inclusion of numbers like 14.29.30133 doesn't allow the script to be very generic.
In the earlier generations of VS, nmake paths were like: C:\Program Files\Microsoft Visual Studio 10.0\Vc\bin or C:\Program Files (x86)\Microsoft Visual Studio 11.0\Vc\bin
Maybe I installed MSVC incorrectly? Any help is appreciated. TIA.
You installed MSVC correctly, and yes, this can cause some headaches, because the version number in the folder name changes with every new minor release of VS 2019.
To resolve this, use this command line snippet for getting the path to the latest installed nmake.exe into the variable %NMAKE%:
set VSPATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional
for /f %%i in ('dir "%VSPATH%\VC\Tools\MSVC" /b') do set VCTOOLSVERSION=%%i
set NMAKE="%VSPATH%\VC\Tools\MSVC\%VCTOOLSVERSION%\bin\HostX86\x86\nmake.exe"
This works for all intermediate versions of Visual Studio 2019 I tested it with.

TFS build dosn't complete correctly when I use c# 7 feature in my code

I've installed TFS (version 15.112.26307.0) on windows server 2012 R2. all team members use VS2017 to coding. I've created an agent (I've tried versions vsts-agent-win7-x64-2.112.0, 2.117.0 ,2.140.0)and set it's MSBuild version to MSBuild15.0 :
MSBuild15.0 has already installed on the server :
But when we use c# 7 features in our code(like "int out x") building code via TFS raise error as below (it use MSBuild14.0 to build our code, why?)
My agent capabalities is not correct :
Use the Visual Studio Build task. It allows you to specify the Visual Studio version used to run builds.
Seems the capabilities cannot be detected by the agent. If you have installed the VS 2017 on the build agent server, then you can try to restart the agent service to check if that works.
If that still not work, you could try below things:
Add the capabilities manually.
The path of them are(Enterprise version for example):
VisualStudio_15.0 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\
VisualStudio_IDE_15.0 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\
MSBuild_15.0 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\
MSBuild_15.0_x64 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\
VSTest C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common\IDE\CommonExtensions\Microsoft\TestWindow
Specify the path to Msbuild 15.0:

How do you install TFS Command Line Tools for Visual Studio 2017

I've installed visual studio 2017 enterprise and the new stand alone Team Explorer 2017. There doesn't seem to be an option in either to add tfs command line tools or tfs shell integration. this implies that it's an extension, but I haven't found anything on the visual studio marketplace. I'd prefer not to reinstall 2015 to use the 2015 power tools, but there is no tf.exe anywhere on my box.
According to TFS 2017 RTW release notes, most of the previous Power Tools have been integrated into TFS 2017, that means no separate power tools, you don't need to install that separately. The Process Template Editor is one that has not been integrated, but you can get it in the Visual Studio Marketplace.
Visual Studio 2017 users: The tf.exe binary is no longer in a fixed
location in the Visual Studio install path as in previous releases
(for example, C:\Program Files (x86)\Microsoft Visual Studio
14.0\Common7\IDE). Scripts using tf.exe should not hardcode a path to the file based on the Visual Studio 2017 install path.
Just as mentioned by Dave, the tf.exe should be under the path :
C:\Program Files (x86)\Microsoft Visual Studio\2017\{Version: Enterprise,Professional,Community}\Common7\IDE\CommonExtensions\Microsof‌​t\TeamFoundation\Tea‌​m Explorer\TF.exe
In most cases, you run the version control command in the context of a directory that is mapped in the workspace. For example, $/SiteApp/Main/ is mapped to c:\\code\\SiteApp\\Main\\. To get the latest version of all items in the workspace:
c:\code\SiteApp\Main\SolutionA>tf get

No agent could be found with the following capabilities: msbuild, visualstudio, vstest

I have TFS On-Premises, and I have this errror when queueing a new build.
No agent could be found with the following capabilities: msbuild, visualstudio, vstest
I found this answer: No agent could be found with the following capabilities: msbuild, visualstudio, vstest?
But is there any way to fix it on-premises without installing Visual Studio on the build server?
I had this issue with Visual Studio 2017 installed on the build server (on-prem):
No agent could be found with the followin capabilities msbuild,visualstudio, vstest
When I upgraded a Test Controller the Build Agent lost some of its capabilities, such as VSTest:
I added these capabilities back as User Capabilities:
MSBuild_15.0 = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\
MSBuild_15.0_x64 = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\
VSTest = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow
VSTest_15.0 = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow
VisualStudio = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\
VisualStudio_15.0 = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\
VisualStudio_IDE = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\
VisualStudio_IDE_15.0 = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\
Then I got the infamous error:
MSBuild not found for version '15.0' and architecture 'x86'
I searched the web high and low, I did so many things to try and resolve this issue, I finally found this saying its been fixed in TFS update 2.
I upgraded TFS from update 1 to 2 and that did fix the problem.
If you don't want to install VS on the build server you could add a new build agent and install VS there.

Where can i find Microsoft.TeamFoundation.Controls.dll for TFS 2015

I`m building an extension for Visual Studio Team Explorer and a line of code like this:
ITeamExplorer teamExplorer = GetService<ITeamExplorer>();
needs a reference to Microsoft.TeamFoundation.Controls.dll
which i couldn't find any where in TFS2015
I have VS 2015 Pro installed. Found it at
**C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer**Microsoft.TeamFoundation.Controls.dll
If you have Visual Studio 2015 installed you should be able to find it at C:\Program Files\Common Files\microsoft shared\Team Foundation Server\14.0\Microsoft.TeamFoundation.Controls.dll; at least, that's where it is on my machine.
Also, I'm not sure if it's required, but I also have the Visual Studio Extensibility Tools installed, which is one of the optional items listed during the installation of Visual Studio 2015.
You can search and find it under this path:C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions
I found it under C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\mcjvkcdg.wd1 on my dev machine.

Resources