Sonarscanner c# sensor produces empty analysis if parent path of source includes a symbolic link

  • versions used :
    SonarQube Version 8.9.2.46101, with 18 extensions (SonarQube, Scanner, Plugin, and any relevant extension)
    C# Code Quality and Security 8.22.0.31243 (csharp)
    SonarScanner 4.6.2.2472
    Java 16 Oracle Corporation (64-bit)

  • error observed: Warn: File is not anaylysed, File referenced by the protobuf does not exist in the analysis context

  • steps to reproduce: create a symbolic link to the source directory, change to the symbolic directory, so you see the name of the link, and 1.start sonarscanner, 2.build and 3. end sonarscanner

  • potential workaround: find out that your path includes a symbolic link, so resolve this lsymbolic, and change (cd) to the resolved (target) directory

3:12:45.593 DEBUG: 'Generic Coverage Report' skipped because one of the required properties is missing
13:12:45.598 DEBUG: 'C# Tests Coverage Report Import' skipped because one of the required properties is missing
13:12:45.598 DEBUG: '[Deprecated] C# Integration Tests Coverage Report Import' skipped because one of the required properties is missing
13:12:45.599 DEBUG: 'C# Unit Test Results Import' skipped because one of the required properties is missing
13:12:45.600 DEBUG: 'VB.NET' skipped because there is no related file in current project
13:12:45.600 DEBUG: 'VB.NET Tests Coverage Report Import' skipped because there is no related file in current project
13:12:45.600 DEBUG: '[Deprecated] VB.NET Integration Tests Coverage Report Import' skipped because there is no related file in current project
13:12:45.602 DEBUG: 'VB.NET Unit Test Results Import' skipped because there is no related file in current project
13:12:45.602 DEBUG: 'Java CPD Block Indexer' skipped because there is no related file in current project
13:12:45.603 DEBUG: Sensors : C# -> Zero Coverage Sensor
13:12:45.603 INFO: Sensor C# [csharp]
13:12:45.620 INFO: Importing results from 5 proto files in '**C:\Users\SonarUser\gr\builds**\ABC\0\projects\myproject\.sonarqube\out\2\output-cs'
13:12:45.629 WARN: File '**D:\gitlab-runner\builds**\ABC\0\projects\myproject\MyApp\MyApp.cs' referenced by the protobuf 'MetricsInfo' does not exist in the analysis context

where builds is a Symolic link
C:\Users\SonarUser\gr\buildsD:\gitlab-runner\builds

the scanner uses the target of the link which targets to D:\gitlab-runner\builds

the analysis context is use the directory name, which is ‘C:\Users\SonarUser\gr\builds’ (correct behavior)
but the import uses the target, which is ‘D:\gitlab-runner\builds’ (wrong behavior)

Hi @Steffen,

thanks for you feedback. I can confirm the problem and I’ve logged an issue on sonar-dotnet analyzer. You can follow the progress here: Files added as symbolic links are not analyzed · Issue #4966 · SonarSource/sonar-dotnet · GitHub.

Unfortunately I cannot provide an ETA for the fix.

Best regards,
Costin