C# Scanning not working in ADO

SonarQube version: 9.9
Deployed as Docker

I am trying to setup scan for a DotNet project in Azure DevOps. The pipeline fails as Prepare step.

  steps:
  - powershell: |
      Write-Host "##vso[task.setvariable variable=JAVA_HOME;]$(SYSTEM_JDK_17)"
  - task: SonarQubePrepare@5
    inputs:
      SonarQube: 'sonarqube-SANDBOX'
      scannerMode: 'MSBuild'
      projectKey: 'aaa-bbb'
  - task: NuGetToolInstaller@1
  - task: NuGetCommand@2
    inputs:
      restoreSolution: '**\aaa.sln'
  - task: VSBuild@1
    inputs:
      solution: '**\aaa.sln'
      platform: 'Any CPU'
      configuration: 'Release'
  # Run Code Analysis task
  - task: SonarQubeAnalyze@5
  # Publish Quality Gate Result task
  - task: SonarQubePublish@4
    inputs:
      pollingTimeoutSec: '300'

ERROR log.

2024-05-13T17:52:12.6594762Z ##[section]Starting: SonarQubePrepare
2024-05-13T17:52:12.6603589Z ==============================================================================
2024-05-13T17:52:12.6603817Z Task         : Prepare Analysis Configuration
2024-05-13T17:52:12.6603900Z Description  : Prepare SonarQube analysis configuration
2024-05-13T17:52:12.6603993Z Version      : 5.19.1
2024-05-13T17:52:12.6604055Z Author       : sonarsource
2024-05-13T17:52:12.6604131Z Help         : Version: 5.19.1. [More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
2024-05-13T17:52:12.6604416Z ==============================================================================
2024-05-13T17:52:14.4536315Z [command]D:\Agents\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.19.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe begin /k:hrp-services
2024-05-13T17:52:14.5904724Z SonarScanner for MSBuild 5.15
2024-05-13T17:52:14.5905582Z Using the .NET Framework version of the Scanner for MSBuild
2024-05-13T17:52:14.7075121Z Pre-processing started.
2024-05-13T17:52:14.7146280Z Preparing working directories...
2024-05-13T17:52:15.0229434Z 13:52:15.019  Updating build integration targets...
2024-05-13T17:52:15.3103056Z 13:52:15.3  Fetching analysis configuration settings...
2024-05-13T17:52:15.5732982Z 13:52:15.566  Provisioning analyzer assemblies for cs...
2024-05-13T17:52:15.5745757Z 13:52:15.566  Installing required Roslyn analyzers...
2024-05-13T17:52:15.5751978Z 13:52:15.566  Processing plugin: csharp version 8.51.0.59060
2024-05-13T17:52:15.7680388Z 
2024-05-13T17:52:15.7681097Z ##[error]Unhandled Exception:
2024-05-13T17:52:15.7835252Z ##[error]System.IO.InvalidDataException: End of Central Directory record could not be found.
   at System.IO.Compression.ZipArchive.ReadEndOfCentralDirectory()
   at System.IO.Compression.ZipArchive.Init(Stream stream, ZipArchiveMode mode, Boolean leaveOpen)
   at System.IO.Compression.ZipFile.Open(String archiveFileName, ZipArchiveMode mode, Encoding entryNameEncoding)
   at System.IO.Compression.ZipFile.ExtractToDirectory(String sourceArchiveFileName, String destinationDirectoryName, Encoding entryNameEncoding)
   at SonarScanner.MSBuild.PreProcessor.Roslyn.EmbeddedAnalyzerInstaller.FetchResourceFromServer(Plugin plugin, String targetDir)
   at SonarScanner.MSBuild.PreProcessor.Roslyn.EmbeddedAnalyzerInstaller.GetPluginResourceFiles(Plugin plugin)
   at SonarScanner.MSBuild.PreProcessor.Roslyn.EmbeddedAnalyzerInstaller.InstallAssemblies(IEnumerable`1 plugins)
   at SonarScanner.MSBuild.PreProcessor.Roslyn.RoslynAnalyzerProvider.FetchAnalyzerPlugins(String language, IEnumerable`1 activeRules)
   at SonarScanner.MSBuild.PreProcessor.Roslyn.RoslynAnalyzerProvider.SetupAnalyzer(BuildSettings teamBuildSettings, IAnalysisPropertyProvider sonarProperties, IEnumerable`1 rules, String language)
   at SonarScanner.MSBuild.PreProcessor.PreProcessor.<FetchArgumentsAndRuleSets>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.PreProcessor.PreProcessor.<DoExecute>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.PreProcessor.PreProcessor.<Execute>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.BootstrapperClass.<PreProcess>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.BootstrapperClass.<Execute>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.Program.<Execute>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.Program.<Execute>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.Program.<Main>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at SonarScanner.MSBuild.Program.<Main>(String[] args)
2024-05-13T17:52:15.7844738Z System.IO.InvalidDataException: End of Central Directory record could not be found.
2024-05-13T17:52:15.7844991Z    at System.IO.Compression.ZipArchive.ReadEndOfCentralDirectory()
2024-05-13T17:52:15.7848176Z    at System.IO.Compression.ZipArchive.Init(Stream stream, ZipArchiveMode mode, Boolean leaveOpen)
2024-05-13T17:52:15.7852753Z    at System.IO.Compression.ZipFile.Open(String archiveFileName, ZipArchiveMode mode, Encoding entryNameEncoding)
2024-05-13T17:52:15.7854172Z    at System.IO.Compression.ZipFile.ExtractToDirectory(String sourceArchiveFileName, String destinationDirectoryName, Encoding entryNameEncoding)
2024-05-13T17:52:15.7855080Z    at SonarScanner.MSBuild.PreProcessor.Roslyn.EmbeddedAnalyzerInstaller.FetchResourceFromServer(Plugin plugin, String targetDir)
2024-05-13T17:52:15.7855893Z    at SonarScanner.MSBuild.PreProcessor.Roslyn.EmbeddedAnalyzerInstaller.GetPluginResourceFiles(Plugin plugin)
2024-05-13T17:52:15.7856669Z    at SonarScanner.MSBuild.PreProcessor.Roslyn.EmbeddedAnalyzerInstaller.InstallAssemblies(IEnumerable`1 plugins)
2024-05-13T17:52:15.7857458Z    at SonarScanner.MSBuild.PreProcessor.Roslyn.RoslynAnalyzerProvider.FetchAnalyzerPlugins(String language, IEnumerable`1 activeRules)
2024-05-13T17:52:15.7859539Z    at SonarScanner.MSBuild.PreProcessor.Roslyn.RoslynAnalyzerProvider.SetupAnalyzer(BuildSettings teamBuildSettings, IAnalysisPropertyProvider sonarProperties, IEnumerable`1 rules, String language)
2024-05-13T17:52:15.7860407Z    at SonarScanner.MSBuild.PreProcessor.PreProcessor.<FetchArgumentsAndRuleSets>d__9.MoveNext()
2024-05-13T17:52:15.7864040Z --- End of stack trace from previous location where exception was thrown ---
2024-05-13T17:52:15.7873569Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2024-05-13T17:52:15.7922014Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2024-05-13T17:52:15.7924339Z    at SonarScanner.MSBuild.PreProcessor.PreProcessor.<DoExecute>d__7.MoveNext()
2024-05-13T17:52:15.7925003Z --- End of stack trace from previous location where exception was thrown ---
2024-05-13T17:52:15.7925510Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2024-05-13T17:52:15.7926051Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2024-05-13T17:52:15.7926560Z    at SonarScanner.MSBuild.PreProcessor.PreProcessor.<Execute>d__6.MoveNext()
2024-05-13T17:52:15.7927060Z --- End of stack trace from previous location where exception was thrown ---
2024-05-13T17:52:15.7928449Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2024-05-13T17:52:15.7929567Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2024-05-13T17:52:15.7930594Z    at SonarScanner.MSBuild.BootstrapperClass.<PreProcess>d__10.MoveNext()
2024-05-13T17:52:15.7931295Z --- End of stack trace from previous location where exception was thrown ---
2024-05-13T17:52:15.7931787Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2024-05-13T17:52:15.7932288Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2024-05-13T17:52:15.7932809Z    at SonarScanner.MSBuild.BootstrapperClass.<Execute>d__8.MoveNext()
2024-05-13T17:52:15.7933313Z --- End of stack trace from previous location where exception was thrown ---
2024-05-13T17:52:15.7933788Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2024-05-13T17:52:15.7934336Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2024-05-13T17:52:15.7934820Z    at SonarScanner.MSBuild.Program.<Execute>d__4.MoveNext()
2024-05-13T17:52:15.7935236Z --- End of stack trace from previous location where exception was thrown ---
2024-05-13T17:52:15.7935670Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2024-05-13T17:52:15.7936129Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2024-05-13T17:52:15.7936620Z    at SonarScanner.MSBuild.Program.<Execute>d__3.MoveNext()
2024-05-13T17:52:15.7937028Z --- End of stack trace from previous location where exception was thrown ---
2024-05-13T17:52:15.7937429Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2024-05-13T17:52:15.7937862Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2024-05-13T17:52:15.7938279Z    at SonarScanner.MSBuild.Program.<Main>d__2.MoveNext()
2024-05-13T17:52:15.7938714Z --- End of stack trace from previous location where exception was thrown ---
2024-05-13T17:52:15.7939127Z    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2024-05-13T17:52:15.7939748Z    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2024-05-13T17:52:15.7940157Z    at SonarScanner.MSBuild.Program.<Main>(String[] args)
2024-05-13T17:52:15.8024054Z ##[error]The process 'D:\Agents\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.19.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 3762504530
2024-05-13T17:52:15.8154622Z ##[section]Finishing: SonarQubePrepare

Hi,

This looks like an error unzipping the analyzers downloaded from SonarQube. You should talk to your network folks, because I believe something “helpful” on the network has interfered with the transmission of the files.

 
HTH,
Ann

Hi,

I do not see any zip file. On the agent server, under ADO “_work/tasks” directory, I can see “SonarQube Analyzers, Prepare, Publish” folders and all the DLLs inside that. Would you please guide me to exact location or the file it is trying to download/extract?

FYI, I’m able to scan java projects. Only for C#, getting this issue. So I’m wondering if this is really a network issue.

Regards,
Aakash

Hi,

I think I figured out the solution. It was trying to download something from SonarQube & that particular endpoint was redirected to our Proxy authentication.

Please delete this ticket. Appreciate your help on this.