Sonarcloud analysis for .NET code in Azure Devops pipelines shows 0 lines of code

Repo- Azure Devops repos
CI Tool- Azure Devops
Steps added in Azure Devops pipeline-

  1. Prepare Analysis on Sonarcloud
  2. Run Code Analysis
  3. Publish Quality Gate Results

The pipeline succeeds & sonarcloud shows that it has scanned but its not scanning anything, shows 0 lines of code , no bugs, vulnerabilities or errors at all. I am using a self hosted build agent in pipeline & classic editor to configure pipeline.

The logs for “Run Code Analysis” step are as follows-
2023-09-25T11:31:15.9412032Z [command]C:\Windows\system32\cmd.exe /D /S /C "D:\a\_tasks\SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1\1.41.0\sonar-scanner\bin\sonar-scanner.bat" 2023-09-25T11:31:21.8919651Z INFO: Scanner configuration file: D:\a\_tasks\SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1\1.41.0\sonar-scanner\bin\..\conf\sonar-scanner.properties 2023-09-25T11:31:22.0175005Z INFO: Project root configuration file: NONE 2023-09-25T11:31:22.6233792Z INFO: SonarScanner 4.8.0.2856 2023-09-25T11:31:22.6234335Z INFO: Java 17.0.8.1 Eclipse Adoptium (64-bit) 2023-09-25T11:31:22.6234785Z INFO: Windows Server 2019 10.0 amd64 2023-09-25T11:31:28.1319538Z INFO: User cache: C:\Users\VssAdministrator\.sonar\cache 2023-09-25T11:31:33.1991597Z INFO: Analyzing on SonarCloud 2023-09-25T11:31:33.1992922Z INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent) 2023-09-25T11:31:36.0857686Z INFO: Load global settings 2023-09-25T11:31:36.4339773Z INFO: Load global settings (done) | time=355ms 2023-09-25T11:31:36.4384306Z INFO: Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu 2023-09-25T11:31:36.4937326Z INFO: User cache: C:\Users\VssAdministrator\.sonar\cache 2023-09-25T11:31:36.4938085Z INFO: Loading required plugins 2023-09-25T11:31:36.4938542Z INFO: Load plugins index 2023-09-25T11:31:36.9174665Z INFO: Load plugins index (done) | time=428ms 2023-09-25T11:31:36.9175901Z INFO: Load/download plugins 2023-09-25T11:31:41.3361893Z INFO: Load/download plugins (done) | time=4421ms 2023-09-25T11:31:42.3973975Z INFO: Loaded core extensions: developer-scanner 2023-09-25T11:31:43.2440192Z INFO: Found an active CI vendor: 'Azure DevOps' 2023-09-25T11:31:43.2678169Z INFO: Load project settings for component key: 'dlssit_OCR' 2023-09-25T11:31:43.5074817Z INFO: Load project settings for component key: 'dlssit_OCR' (done) | time=244ms 2023-09-25T11:31:43.5336906Z INFO: Process project properties 2023-09-25T11:31:43.5446161Z INFO: Execute project builders 2023-09-25T11:31:43.5446815Z INFO: Execute project builders (done) | time=2ms 2023-09-25T11:31:43.5480473Z INFO: Project key: dlssit_OCR 2023-09-25T11:31:43.5480967Z INFO: Base dir: D:\a\1\s 2023-09-25T11:31:43.5481403Z INFO: Working dir: D:\a\1\s\.scannerwork 2023-09-25T11:31:44.5312956Z INFO: Load project branches 2023-09-25T11:31:44.7956138Z INFO: Load project branches (done) | time=260ms 2023-09-25T11:31:44.7956731Z INFO: Check ALM binding of project 'dlssit_OCR' 2023-09-25T11:31:45.0122378Z INFO: Detected project binding: BOUND 2023-09-25T11:31:45.0123262Z INFO: Check ALM binding of project 'dlssit_OCR' (done) | time=209ms 2023-09-25T11:31:45.0123735Z INFO: Load project pull requests 2023-09-25T11:31:45.2232677Z INFO: Load project pull requests (done) | time=214ms 2023-09-25T11:31:45.2267496Z INFO: Load branch configuration 2023-09-25T11:31:45.2487378Z INFO: Load branch configuration (done) | time=3ms 2023-09-25T11:31:45.2488469Z INFO: Load quality profiles 2023-09-25T11:31:45.5729736Z INFO: Load quality profiles (done) | time=326ms 2023-09-25T11:31:45.5835176Z INFO: Load active rules 2023-09-25T11:31:55.9778391Z INFO: Load active rules (done) | time=10376ms 2023-09-25T11:31:56.0192887Z INFO: Exclusions based on SCM info is disabled by configuration 2023-09-25T11:31:56.2354097Z INFO: Organization key: eversana 2023-09-25T11:31:56.4244896Z INFO: Load project repositories 2023-09-25T11:31:56.6906010Z INFO: Load project repositories (done) | time=260ms 2023-09-25T11:31:56.7377860Z INFO: Indexing files... 2023-09-25T11:31:56.7378926Z INFO: Project configuration: 2023-09-25T11:31:56.7382440Z INFO: Excluded sources: **/build-wrapper-dump.json 2023-09-25T11:31:56.7777613Z INFO: 1 file indexed 2023-09-25T11:31:56.7785537Z INFO: 0 files ignored because of inclusion/exclusion patterns 2023-09-25T11:31:59.0452489Z INFO: Loading plugins for detected languages 2023-09-25T11:31:59.0460448Z INFO: Load/download plugins 2023-09-25T11:31:59.0461217Z INFO: Load/download plugins (done) | time=1ms 2023-09-25T11:31:59.1271735Z INFO: ------------- Run sensors on module OCR 2023-09-25T11:31:59.3627720Z INFO: Load metrics repository 2023-09-25T11:31:59.5944676Z INFO: Load metrics repository (done) | time=218ms 2023-09-25T11:31:59.5945902Z INFO: Sensor cache enabled 2023-09-25T11:31:59.5946603Z INFO: Load sensor cache 2023-09-25T11:32:00.1826801Z INFO: Load sensor cache (404) | time=586ms 2023-09-25T11:32:05.3907541Z INFO: Sensor C# Project Type Information [csharp] 2023-09-25T11:32:05.6231759Z INFO: Sensor C# Project Type Information [csharp] (done) | time=2ms 2023-09-25T11:32:05.6237269Z INFO: Sensor C# Analysis Log [csharp] 2023-09-25T11:32:05.6238091Z INFO: Sensor C# Analysis Log [csharp] (done) | time=17ms 2023-09-25T11:32:05.6238477Z INFO: Sensor C# Properties [csharp] 2023-09-25T11:32:05.6238840Z INFO: Sensor C# Properties [csharp] (done) | time=0ms 2023-09-25T11:32:05.6239308Z INFO: Sensor HTML [web] 2023-09-25T11:32:05.6239661Z INFO: Sensor HTML [web] (done) | time=3ms 2023-09-25T11:32:05.6240152Z INFO: Sensor TextAndSecretsSensor [text] 2023-09-25T11:32:05.9591617Z INFO: Sensor TextAndSecretsSensor [text] (done) | time=566ms 2023-09-25T11:32:05.9682410Z INFO: Sensor VB.NET Project Type Information [vbnet] 2023-09-25T11:32:05.9683044Z INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=1ms 2023-09-25T11:32:05.9683394Z INFO: Sensor VB.NET Analysis Log [vbnet] 2023-09-25T11:32:05.9888045Z INFO: Sensor VB.NET Analysis Log [vbnet] (done) | time=19ms 2023-09-25T11:32:05.9891528Z INFO: Sensor VB.NET Properties [vbnet] 2023-09-25T11:32:05.9892319Z INFO: Sensor VB.NET Properties [vbnet] (done) | time=1ms 2023-09-25T11:32:05.9893699Z INFO: Sensor JaCoCo XML Report Importer [jacoco] 2023-09-25T11:32:05.9894236Z INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml 2023-09-25T11:32:05.9894775Z INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer 2023-09-25T11:32:05.9895660Z INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=3ms 2023-09-25T11:32:05.9896088Z INFO: Sensor CSS Rules [javascript] 2023-09-25T11:32:05.9896779Z INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped. 2023-09-25T11:32:05.9897123Z INFO: Sensor CSS Rules [javascript] (done) | time=0ms 2023-09-25T11:32:05.9897429Z INFO: Sensor ThymeLeaf template sensor [securityjavafrontend] 2023-09-25T11:32:05.9897777Z INFO: Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=0ms 2023-09-25T11:32:05.9898099Z INFO: Sensor IaC Docker Sensor [iac] 2023-09-25T11:32:06.0717636Z INFO: 0 source files to be analyzed 2023-09-25T11:32:06.1161532Z INFO: 0/0 source files have been analyzed 2023-09-25T11:32:06.1181865Z INFO: Sensor IaC Docker Sensor [iac] (done) | time=129ms 2023-09-25T11:32:06.1182689Z INFO: Sensor Serverless configuration file sensor [security] 2023-09-25T11:32:06.1183411Z INFO: 0 Serverless function entries were found in the project 2023-09-25T11:32:06.2140398Z INFO: 0 Serverless function handlers were kept as entrypoints 2023-09-25T11:32:06.2150825Z INFO: Sensor Serverless configuration file sensor [security] (done) | time=98ms 2023-09-25T11:32:06.2153478Z INFO: Sensor AWS SAM template file sensor [security] 2023-09-25T11:32:06.2177353Z INFO: Sensor AWS SAM template file sensor [security] (done) | time=1ms 2023-09-25T11:32:06.2177884Z INFO: Sensor AWS SAM Inline template file sensor [security] 2023-09-25T11:32:06.2178347Z INFO: Sensor AWS SAM Inline template file sensor [security] (done) | time=1ms 2023-09-25T11:32:06.2178690Z INFO: Sensor javabugs [dbd] 2023-09-25T11:32:06.2196977Z INFO: Reading IR files from: D:\a\1\s\.scannerwork\ir\java 2023-09-25T11:32:06.2197445Z INFO: No IR files have been included for analysis. 2023-09-25T11:32:06.2199384Z INFO: Sensor javabugs [dbd] (done) | time=2ms 2023-09-25T11:32:06.2201702Z INFO: Sensor pythonbugs [dbd] 2023-09-25T11:32:06.2202163Z INFO: Reading IR files from: D:\a\1\s\.scannerwork\ir\python 2023-09-25T11:32:06.2203659Z INFO: No IR files have been included for analysis. 2023-09-25T11:32:06.2203999Z INFO: Sensor pythonbugs [dbd] (done) | time=0ms 2023-09-25T11:32:06.2204351Z INFO: Sensor JavaSecuritySensor [security] 2023-09-25T11:32:06.2435430Z INFO: Enabled taint analysis rules: S2076, S2078, S2083, S2091, S2631, S3649, S5131, S5135, S5144, S5145, S5146, S5147, S5334, S5883, S6096, S6173, S6287, S6350, S6384, S6390, S6398, S6399, S6547, S6549 2023-09-25T11:32:06.2493870Z INFO: Load type hierarchy and UCFGs: Starting 2023-09-25T11:32:06.2494569Z INFO: Load type hierarchy: Starting 2023-09-25T11:32:06.2494985Z INFO: Reading type hierarchy from: D:\a\1\s\.scannerwork\ucfg2\java 2023-09-25T11:32:06.2505991Z INFO: Read 0 type definitions 2023-09-25T11:32:06.2506557Z INFO: Load type hierarchy: Time spent was 00:00:00.019 2023-09-25T11:32:06.2506925Z INFO: Load UCFGs: Starting 2023-09-25T11:32:06.2507350Z INFO: Load UCFGs: Time spent was 00:00:00.000 2023-09-25T11:32:06.2509269Z INFO: Load type hierarchy and UCFGs: Time spent was 00:00:00.020 2023-09-25T11:32:06.2510195Z INFO: No UCFGs have been included for analysis. 2023-09-25T11:32:06.2516922Z INFO: java security sensor: Time spent was 00:00:00.027 2023-09-25T11:32:06.5391209Z INFO: Sensor JavaSecuritySensor [security] (done) | time=295ms 2023-09-25T11:32:06.5549928Z INFO: Sensor CSharpSecuritySensor [security] 2023-09-25T11:32:06.5763591Z INFO: Enabled taint analysis rules: S2076, S2078, S2083, S2091, S2631, S3649, S5131, S5135, S5144, S5145, S5146, S5334, S5883, S6096, S6173, S6287, S6350, S6639, S6641 2023-09-25T11:32:06.5764283Z INFO: Load type hierarchy and UCFGs: Starting 2023-09-25T11:32:06.5764919Z INFO: Load type hierarchy: Starting 2023-09-25T11:32:06.5765344Z INFO: Reading type hierarchy from: D:\a\1\s\ucfg_cs2 2023-09-25T11:32:06.5765677Z INFO: Read 0 type definitions 2023-09-25T11:32:06.5766049Z INFO: Load type hierarchy: Time spent was 00:00:00.001 2023-09-25T11:32:06.5766422Z INFO: Load UCFGs: Starting 2023-09-25T11:32:06.5766758Z INFO: Load UCFGs: Time spent was 00:00:00.000 2023-09-25T11:32:06.5767096Z INFO: Load type hierarchy and UCFGs: Time spent was 00:00:00.001 2023-09-25T11:32:06.5767472Z INFO: No UCFGs have been included for analysis. 2023-09-25T11:32:06.5767822Z INFO: csharp security sensor: Time spent was 00:00:00.002 2023-09-25T11:32:06.5768186Z INFO: Sensor CSharpSecuritySensor [security] (done) | time=5ms 2023-09-25T11:32:06.5768500Z INFO: Sensor PhpSecuritySensor [security] 2023-09-25T11:32:06.5768912Z INFO: Enabled taint analysis rules: S2076, S2078, S2083, S2091, S2631, S3649, S5131, S5135, S5144, S5145, S5146, S5334, S5335, S5883, S6173, S6287, S6350 2023-09-25T11:32:06.5771251Z INFO: Load type hierarchy and UCFGs: Starting 2023-09-25T11:32:06.5771707Z INFO: Load type hierarchy: Starting 2023-09-25T11:32:06.5772075Z INFO: Reading type hierarchy from: D:\a\1\s\.scannerwork\ucfg2\php 2023-09-25T11:32:06.5774058Z INFO: Read 0 type definitions 2023-09-25T11:32:06.5774410Z INFO: Load type hierarchy: Time spent was 00:00:00.001 2023-09-25T11:32:06.5774756Z INFO: Load UCFGs: Starting 2023-09-25T11:32:06.5776761Z INFO: Load UCFGs: Time spent was 00:00:00.000 2023-09-25T11:32:06.5777116Z INFO: Load type hierarchy and UCFGs: Time spent was 00:00:00.002 2023-09-25T11:32:06.5777467Z INFO: No UCFGs have been included for analysis. 2023-09-25T11:32:06.5777803Z INFO: php security sensor: Time spent was 00:00:00.004 2023-09-25T11:32:06.5778126Z INFO: Sensor PhpSecuritySensor [security] (done) | time=4ms 2023-09-25T11:32:06.5778457Z INFO: Sensor PythonSecuritySensor [security] 2023-09-25T11:32:06.5778850Z INFO: Enabled taint analysis rules: S2076, S2078, S2083, S2091, S2631, S3649, S5131, S5135, S5144, S5145, S5146, S5147, S5334, S5496, S6287, S6350 2023-09-25T11:32:06.5779217Z INFO: Load type hierarchy and UCFGs: Starting 2023-09-25T11:32:06.5779577Z INFO: Load type hierarchy: Starting 2023-09-25T11:32:06.5779947Z INFO: Reading type hierarchy from: D:\a\1\s\.scannerwork\ucfg2\python 2023-09-25T11:32:06.5780265Z INFO: Read 0 type definitions 2023-09-25T11:32:06.5781539Z INFO: Load type hierarchy: Time spent was 00:00:00.000 2023-09-25T11:32:06.5781921Z INFO: Load UCFGs: Starting 2023-09-25T11:32:06.5782296Z INFO: Load UCFGs: Time spent was 00:00:00.000 2023-09-25T11:32:06.5782705Z INFO: Load type hierarchy and UCFGs: Time spent was 00:00:00.000 2023-09-25T11:32:06.5783080Z INFO: No UCFGs have been included for analysis. 2023-09-25T11:32:06.5783421Z INFO: python security sensor: Time spent was 00:00:00.001 2023-09-25T11:32:06.5783860Z INFO: Sensor PythonSecuritySensor [security] (done) | time=3ms 2023-09-25T11:32:06.5784359Z INFO: Sensor JsSecuritySensor [security] 2023-09-25T11:32:06.5784717Z INFO: Enabled taint analysis rules: S3649, S6105, S2083, S6350, S2076, S6096, S5883, S2631, S5146, S5334, S5131, S6287, S5144, S5147, S5696 2023-09-25T11:32:06.5785099Z INFO: Load type hierarchy and UCFGs: Starting 2023-09-25T11:32:06.5785395Z INFO: Load type hierarchy: Starting 2023-09-25T11:32:06.5785690Z INFO: Reading type hierarchy from: D:\a\1\s\.scannerwork\ucfg2\js 2023-09-25T11:32:06.5786001Z INFO: Read 0 type definitions 2023-09-25T11:32:06.5786322Z INFO: Load type hierarchy: Time spent was 00:00:00.000 2023-09-25T11:32:06.5786634Z INFO: Load UCFGs: Starting 2023-09-25T11:32:06.5786942Z INFO: Load UCFGs: Time spent was 00:00:00.000 2023-09-25T11:32:06.5787277Z INFO: Load type hierarchy and UCFGs: Time spent was 00:00:00.000 2023-09-25T11:32:06.5787581Z INFO: No UCFGs have been included for analysis. 2023-09-25T11:32:06.5787901Z INFO: js security sensor: Time spent was 00:00:00.001 2023-09-25T11:32:06.5788233Z INFO: Sensor JsSecuritySensor [security] (done) | time=2ms 2023-09-25T11:32:06.5788687Z INFO: ------------- Run sensors on project 2023-09-25T11:32:06.6137283Z INFO: Sensor Analysis Warnings import [csharp] 2023-09-25T11:32:06.6138175Z INFO: Sensor Analysis Warnings import [csharp] (done) | time=1ms 2023-09-25T11:32:06.6139477Z INFO: Sensor Zero Coverage Sensor 2023-09-25T11:32:06.6140368Z INFO: Sensor Zero Coverage Sensor (done) | time=6ms 2023-09-25T11:32:06.6334943Z INFO: CPD Executor Calculating CPD for 0 files 2023-09-25T11:32:06.6335894Z INFO: CPD Executor CPD calculation finished (done) | time=0ms 2023-09-25T11:32:09.4623947Z INFO: Analysis report generated in 2846ms, dir size=220 KB 2023-09-25T11:32:09.4820426Z INFO: Analysis report compressed in 14ms, zip size=41 KB 2023-09-25T11:32:09.8096535Z INFO: Analysis report uploaded in 333ms 2023-09-25T11:32:09.8134754Z INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=dlssit_OCR 2023-09-25T11:32:09.8135400Z INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report 2023-09-25T11:32:09.8136053Z INFO: More about the report processing at https://sonarcloud.io/api/ce/task?id=AYrMHG1OwHPLPD8SQbF2 2023-09-25T11:32:09.8204594Z INFO: Analysis total time: 27.423 s 2023-09-25T11:32:09.8296617Z INFO: ------------------------------------------------------------------------ 2023-09-25T11:32:09.8708562Z INFO: EXECUTION SUCCESS 2023-09-25T11:32:09.8711673Z INFO: ------------------------------------------------------------------------ 2023-09-25T11:32:09.8712118Z INFO: Total time: 48.190s 2023-09-25T11:32:09.9393171Z INFO: Final Memory: 38M/130M />

Hey there.

It looks like you only have one file being indexed.

1 file indexed

Where are your files located? Under this directory?

INFO: Base dir: D:\a\1\s

The files to be scanned are located in Azure Devops repo ; branch :Master
I am not from a dev background hence would like suggestions whether why the my code isn’t being scanned , I have tried using my own created quality gate & also included - “sonar.scm.exclusions.disabled=true” in Prepare analysis step . I have followed the documentation for sonarcloud setup for .NET code .
Is there any setting/ file to be configured on build agent? Should we use self hosted or ms hosted build agent?

Let’s step back a bit.

Can you paste your Azure DevOps Pipeline YML here to show exactly how it’s configured?

Can you point me to which documentation you’re following?

Hello Colin,

I have configured a classic pipeline & please see the screenshot below for same-




I have referred to this page for setting up Sonarcloud- Azure DevOps | SonarCloud Docs

Most of the time with 0 lines of code can be solved by 2 cases.

  • one is to disable the scm : sonar.scm.disabled=true
  • another one is to force the solution (csproj) to not being considered as test with PropertyGroup: SonarQubeTestProject>false</SonarQubeTestProject

Hey there.

It looks like you’re using the standalone scanner instead fo the Scanner for .NET, which is required to analyze .NET code.

You should check “Integrate with MSBuild”

Thanks Colin!
When selecting “Integrate with MSBuild” , I get an error as attached in screenshot.

Hm. There should be no difference here.

Does switching back to the standalone scanner really make it connect again?

Are the builds running on different agents/agent pools?