Using MSTest.TestAdapter causes file is not located under the root directory warning

Which versions are you using

  • SonarQube 8.9 (build 43852)
  • SonarScanner for MSBuild 5.0.4

What are you trying to achieve
We are trying to solve the following warnings from the SonarScanner:

  • 11:54:11.528 11:54:11.528 WARNING: File ‘C:\Users\CIUser.nuget\packages\mstest.testadapter\2.2.4\build_common\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll’ is not located under the root directory ‘H:\workspace\SmartTranslator_nightly’ and will not be analyzed.
  • 11:54:11.528 11:54:11.528 WARNING: File ‘C:\Users\CIUser.nuget\packages\mstest.testadapter\2.2.4\build_common\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll’ is not located under the root directory ‘H:\workspace\SmartTranslator_nightly’ and will not be analyzed.
  • 11:54:11.528 11:54:11.528 WARNING: File ‘C:\Users\CIUser.nuget\packages\mstest.testadapter\2.2.4\build_common\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll’ is not located under the root directory ‘H:\workspace\SmartTranslator_nightly’ and will not be analyzed.
  • 11:54:11.528 11:54:11.528 WARNING: File ‘C:\Users\CIUser.nuget\packages\mstest.testadapter\2.2.4\build\net45\Microsoft.TestPlatform.AdapterUtilities.dll’ is not located under the root directory ‘H:\workspace\SmartTranslator_nightly’ and will not be analyzed.

What have you tried so far to achieve this
Because the MSTest.TestAdapter package was outdated, we first tried to update it to the latest version, but nothing changed.
We found this File is not located under the root directory and will not be analyzed which is the same warning. We do not include the problematic files ourselves, but it gave us an idea. An inspection of the package revealed that the files are automatically included by the package. The includes are located in \build\net45\MSTest.TestAdapter.props.

Since this is done by the package itself, it does not look like we can fix it in our project. It seems more like an edge case which needs to be handled by the SonarScanner for MSBuild. Or the configuration of our test project is wrong, and it is not correctly recognized as a test project.

2 Likes

We tested using <None Remove="@(TestAdapterContent)" /> as mentioned in the props-file and the warnings vanished. But so did the test results because no tests were discovered in the test assembly.

Hi @x3ntrix,

this seems to be an issue on our side and not a configuration problem with your project.

I’ve created this issue where you can track the progress: Warnings are raised for files added by NuGet packages · Issue #1032 · SonarSource/sonar-scanner-msbuild · GitHub and you can ignore them for now, until the issue is fixed.

Thanks,
Costin