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”