Title:
SonarCloud Azure DevOps task fails with Newtonsoft.Json MissingMethodException in scanner ≥ 11.x (works when pinned to 10.4.1)
Description:
After upgrading the SonarCloud Azure DevOps integration to versions using .NET scanner 11.x (≥ 11.0.0.126294), pipelines started failing consistently during analysis with a runtime exception related to Newtonsoft.Json.
This issue occurs when using:
-
SonarCloudPrepare@4(scannerMode: dotnet) -
Azure DevOps pipelines (self-hosted agent)
-
Modern .NET SDK (tested with .NET 10)
Error Output:
##[error]Unhandled Exception:
##[error]System.MissingMethodException: Method not found:
'System.String Newtonsoft.Json.Linq.JToken.ToString(Newtonsoft.Json.Formatting)'.
Expected Behavior:
SonarCloud analysis should run successfully using the latest scanner version without runtime dependency conflicts.
Actual Behavior:
Pipeline fails during Sonar analysis phase with MissingMethodException, indicating a runtime dependency mismatch.
Key Finding / Regression Evidence:
The issue is version-specific and reproducible:
-
Scanner 11.x (≥ 11.0.0.126294) → fails -
Scanner 10.4.1.124928 → works reliably
This confirms a regression introduced in scanner 11.x.
Working Configuration (Workaround):
- task: SonarCloudPrepare@4
inputs:
SonarQube: 'SonarQube Cloud Service'
organization: 'organization'
scannerMode: 'dotnet'
dotnetScannerVersion: '10.4.1.124928'
projectKey: 'projectKey'
extraProperties: |
sonar.exclusions=**/bin/**,**/obj/**,**/Migrations/**,**/*.Designer.cs,**/*.g.cs,**/wwwroot/**
sonar.cs.vscoveragexml.reportsPaths=coverage.xml
sonar.coverage.exclusions=**/*.g.cs,**/*.Designer.cs,**/Migrations/**
Impact:
-
Blocks CI/CD pipelines using SonarCloud Azure DevOps tasks
-
Prevents PR validation and quality gate enforcement
-
Requires manual version pinning
-
Root cause was non-obvious; took ~3 days to diagnose
Suspected Root Cause:
A dependency/runtime incompatibility involving Newtonsoft.Json introduced in scanner 11.x:
-
Scanner likely depends on a different version of Newtonsoft.Json
-
Azure DevOps agent runtime loads another version
-
Results in method resolution failure (
MissingMethodException)
Environment:
-
Azure DevOps (self-hosted agent, Windows)
-
SonarCloud Azure DevOps Extension
-
Scanner:
-
Failing: ≥ 11.0.0.126294
-
Working: 10.4.1.124928
-
-
.NET SDK: 10.0.x
-
Java: JDK 21
Severity: High
(Breaks CI pipelines and PR analysis)
Recommendation:
-
Fix dependency packaging / binding compatibility in scanner 11.x
-
Ensure isolated runtime dependencies (avoid host conflicts)
-
Add clearer diagnostics for dependency loading failures
