SonarScanner .NET on Windows: dll locked after analysis

We are running SonarScanner for .NET inside a Jenkins Declarative Pipeline on a Windows build agent.
After the scan completes (dotnet sonarscanner end), the Jenkins post‑build cleanup step fails because DLLs inside:

.sonarqube/bin/

— especially Newtonsoft.Json.dll — remain locked by SonarScanner/MSBuild/dotnet processes.

This causes:

java.nio.file.AccessDeniedException: ...\.sonarqube\bin\Newtonsoft.Json.dll

We cannot kill dotnet.exe or SonarScanner.MSBuild.exe using taskkill because multiple Sonar scans and .NET builds may be running concurrently on the same agent.

Looking for an official recommendation from SonarSource on how to reliably ensure .sonarqube/bin is unlocked on Windows before workspace cleanup

Environment

  • SonarQube Server Version: Enterprise Edition v2025.3.1 (109879)

  • SonarScanner for .NET: via dotnet sonarscanner

  • Build Tool: Cake

  • Jenkins: Declarative + Shared Libraries

  • Jenkins Agent OS: Windows Server

  • Workspace Layout:

    D:/Apps/Jenkins/<job>/<build>/...
    
  • Command used:
    bat “${dotnet} sonarscanner begin /k:${projectKey} /d:sonar.cs.opencover.reportsPaths=${coverageReportPath}”
    bat “${dotnet} cake --target Test --nuget_source=${NugetUrl}”
    bat “${dotnet} sonarscanner end”

Hi,

What version of SonarScanner for .NET do you have installed on the build agent?

 
Thx,
Ann

Hi,

I tried with 11.1.0.
{
“version”: 1,
“isRoot”: true,
“tools”: {
“cake.tool”: {
“version”: “4.0.0”,
“commands”: [“dotnet-cake”]
},
“dotnet-sonarscanner”: {
“version”: “11.1.0”,
“commands”: [“dotnet-sonarscanner”]
}
}
}

Jenkins logs-
2026-03-04 13:30:01 D:\Apps\JenkinsAKSPRD\GEBE_formbuilder_backend_CI_Pipeline_feature_cicd_workspace_issue\8>“C:\Program Files\dotnet\dotnet.exe” sonarscanner begin /k:belfius.gebe.formbuilder.backend /d:sonar.cs.opencover.reportsPaths=**/coverage/*.xml
2026-03-04 13:30:03 SonarScanner for .NET 11.1
2026-03-04 13:30:03 Using the .NET Core version of the Scanner for .NET
2026-03-04 13:30:03 Pre-processing started.
2026-03-04 13:30:03 Preparing working directories…

1 Like

Hi,

For the sake of i-dotting, can you provide a full, verbose analysis log, please?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Thx,
Ann

jenkins_dotnet_sonarscanner_debug_log.txt (927.5 KB)

Hi Ann,

Please find the debug logs of the scanner attached.

Hi,

Thanks for the log. I’ll flag this for the team.

 
Ann