Source files are being set in "Test paths" during dotnet sonarscanner analysis

Okay I was going to post this question up, buuuut I managed to find the answer while I was gathering information to post.

In a nutshell the source for my web app and the library projects it was referencing had their source be tagged as “Test paths” rather than “Source paths”. I was using the dotnet sonarscanner tool to scan my code.

The cause ended up being that someone added the NSubstitute nuget library in the library package that was being referenced by the WebApi project. This caused both to be treated as unit tests projects :frowning:

Once I moved the NSubstitute package down into the unit test project, everything worked great again!

Thanks for posting your solution!

Just to make sure it’s linked here, here is a wiki page that describes the detection of product vs. test projects.