sonar-scanner-msbuild icon indicating copy to clipboard operation
sonar-scanner-msbuild copied to clipboard

Output directory is used as a fallback when the base directory cannot be identified

Open costin-zaharia-sonarsource opened this issue 8 months ago • 0 comments

The Scanner for .Net tries to determine the base directory by doing the following checks:

  • if sonar.projectBaseDir property is defined, use the given value
  • if the TF_BUILD_SOURCESDIRECTORY environment variable is defined (Team Build legacy), use the given value
  • if the BUILD_SOURCESDIRECTORY environment variable is defined (TFS 2015), use the given value
  • otherwise, it creates a list with all the paths of the analyzed project and tries to find a common directory that includes all. If the common directory is found, use the computed value.
  • otherwise, the output directory is used.

Analyzing the output directory (baseDirectory\out) is not useful since the user code is not in there.

Source: https://github.com/SonarSource/sonar-scanner-msbuild/blob/5dd8cae89b08b7f435c3cfaf84d763d1f8696188/src/SonarScanner.MSBuild.Shim/PropertiesFileGenerator.cs#L254