One problem that annoyed me for months was the missing code coverage in our build jobs in Azure DevOps. The metric vanished from one day to another for the .Net 4.x projects. Whatever I tried with the options in the Visual Studio Test task, all I could produce was this link to the Microsoft documentation:
Last week I was quick enough to get the *.trx file of the test run before it got deleted by the build agent. At the end of a nearly 18,000 lines long file I got the important notice to solve this problem:
A search in Google got me to an issue on GitHub with an image like this one about the editions of Visual Studio:
Code coverage is only part of the Enterprise edition, but we run the Community edition on the build server. I installed the Enterprise edition and on the next run of the build job the code coverage metric was back:
If you run into the same problem, try to install the enterprise edition. It may solve your missing code coverage as well.