FROM: https://github.com/Microsoft/vsts-agent/issues/1605
Version of your agent? 2.134.2
OS of the machine running the agent? Windows 10, 1803
The agent-machine has VS2017 Professional installed.
VisualStudio.com
If VisualStudio.com, what is your account name? http://scan2lead.visualstudio.com
I use "Visual Studio Test Platform Installer (Preview)" and "Visual Studio Test (v2)" to run my tests. I enabled Code Coverage for them.
The codecoverage.exe files are located at
C:\vstsAgent\_work\_tool\VsTest\15.8.0-preview-20180510-03\x64\tools\net451\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
C:\vstsAgent\_work\_tool\VsTest\15.8.0-preview-20180510-03\x64\tools\net451\Team Tools\Dynamic Code Coverage Tools\amd64\CodeCoverage.exe
but the logs tell me
...
2018-06-05T07:45:52.4833619Z Data collection : Logging DataCollector Diagnostics in file: C:\vstsAgent\_work\_temp\6de4f490-6894-11e8-a094-f7e855a114e8.datacollector.18-06-05_09-45-49_54108_5.txt
2018-06-05T07:45:52.4834750Z Data collector 'Code Coverage' message: Cannot find CodeCoverage.exe..
...
If I run the same tasks on a VSTS Hosted Agent the coverage works.
Agent_20180530-071436-utc.log
Worker_20180605-074323-utc.log
Please ensure you are logging issues to the correct repository in order to get the best support.
If you are hitting a generic issue about VSTS/TFS, please report it to the Developer Community
@SeriousM can you please provide the build/release logs with system.debug=true.
Please upload the entire zip file you get.
Also in the vstest task have you set the test platform version to installed by tools installer?

Also in the vstest task have you set the test platform version to installed by tools installer?
That was the solution. It was set to "Latest" which suggested to select a special version, not a result of a preview executed task.
Thank you. Maybe this could be enhanced to be set automatically or suggested if CodeCoverage.exe wasn't found?
@SeriousM thank you for your feedback. @PBoraMSFT for taking a look at the feedback.
+1 I reproduced this with same version of agent and VS installed
@SeriousM @PBoraMSFT
@jairov4 - Code coverage does not ship in VS Professional edition. You need to use VS Enterprise or use the test platform installer task.
Most helpful comment
@jairov4 - Code coverage does not ship in VS Professional edition. You need to use VS Enterprise or use the test platform installer task.