Parallel ADO pipelines locking SonarScanner.MSBuild.Common.dll

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Developer Edition Version 9.9 (build 65466)
  • how is SonarQube deployed: zip, Docker, Helm
    ZIP deployment behind IIS reverse proxy
  • what are you trying to achieve
    Trying to run an ADO build pipeline for a Monorepo which has parallel stages (each stage initialises and analyses its own portion of the build) in a timely fashion
  • what have you tried so far to achieve this
    To achieve this we have had to set the nodereuse flag (/nr:false) for MSBuild to false which causes our build time to treble
    Without it we get the error Access to the path ‘D:\DevOpsAgents\02_work\3.sonarqube\bin\SonarScanner.MSBuild.Common.dll’ is denied.’ and various stages of the build fail (which is not useful :slight_smile: )

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

Hey there.

This is the correct approach, as far as we know. SonarScanner.MSBuild.Common.dll locked · Issue #535 · SonarSource/sonar-scanner-msbuild · GitHub

Colin ,
I think I have found a way around this issue :smiley:
If you install the scanner from the ZIP file onto the build agent and then, in the build pipeline, configure the MSBuild command to override the SonarQubeTargetsPath MSBuild property, the DLLs are loaded from outside of the build workspace and thus are not locked when the workspace is cleaned down.

To override the property, simply call MSBuild such as “C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe” “D:\DevOpsAgents\04_work\3\s\MyWebApi\MyWebApi.sln” -m -v:m /p:SonarQubeTargetsPath=D:\SQ\sonar-scanner-msbuild-5.14.0.78575-net46\Targets (where D:\SQ\sonar-scanner-msbuild-5.14.0.78575-net46 is where the ZIP file was extracted to)

1 Like

Thanks for the follow-up! I’ll flag this for attention to see if there are any downsides to this or if we could work it into our recommendations overall (or the scanner itself).

1 Like

Hello @DHCSO,

That’s a fairly unusual setup and your workaround seems to be the proper solution for your needs.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.